JavaScripts don't work somehow... very very strange

Forum for you who has PHP installation issues

Moderators: macek, egami, gesf

User avatar
maurits
New php-forum User
New php-forum User
Posts: 31
Joined: Fri Mar 26, 2004 3:27 pm
Location: Eindhoven, The Netherlands

JavaScripts don't work somehow... very very strange

Postby maurits » Fri Apr 09, 2004 1:08 pm

Hey y'all!

The weirdest thing happened. A while ago I started using PHP (after some time using ASP) and created a few working web sites with it (from simple stuff to more intermediate database things) and some Javascript scripts to back some of the client side activities.

However, all of the sudden all my Javascript scripts are not working anymore! I did the following things in an attempt to solve the problem:

1. Check the syntax, dubble-check and recheck. However, the syntax must be correct, because the unchanged page worked fine a week ago, and also because of the following:
2. When visiting the site in Internet Explorer, I copied the source code from the page (that has been finished rendering) and saved it as an *.html file on my desktop to run it from there. The JavaScripts worked fine.
3. I moved the previous *.html file onto the server and loaded it via "http://localhost/*.*". This time the scripts didn't work! :shock:

I really don't get this, mainly because the scripts are client side (naturally) and have nothing to do with PHP or any other server-side scripting (that's also why the scripts did work on the page that was not saved and rendered from the server).

I have no clue as to how to solve this. I also restored the back up of the config file, with no effect at all. It's driving me absolutely nuts! :eek:

Is there anyone who may know how I can solve this?

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Sat Apr 10, 2004 1:21 am

It would be easier if you could show us you javascript code... can you!?

User avatar
maurits
New php-forum User
New php-forum User
Posts: 31
Joined: Fri Mar 26, 2004 3:27 pm
Location: Eindhoven, The Netherlands

Postby maurits » Sat Apr 10, 2004 2:02 am

Of course! My apologies...

Here is the (extremely simple) script of one page, named index.php.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script type="text/javascript" language="JavaScript">
<!--
function word_open(URL) {
window.open(URL, "word", "width=300,height=300,scrollbars=yes");
}
//-->
</script>


<title>The Braintables - How it works</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../styles/sub.css" rel="stylesheet" type="text/css" />
<link href="../styles/index.css" rel="stylesheet" type="text/css" />
<link href="../styles/nav.css" rel="stylesheet" type="text/css" />
</head>


Followed by the site's <body>, where some links are placed with the following code:

Code: Select all

<a target="word" onclick="word_open('../dictionary/show.php?word=consectetuer%20adipiscing'); return false;" href="../dictionary/show.php?word=consectetuer%20adipiscing" class="blue">consectetuer adipiscing</a>


When the link is clicked, a new pop-up window should appear with the file "show.php" that shows the meaning of the word. And, of course, it worked. But now all of the sudden it just opens the link in a new window as if the link's target was "_new".

I also tried to check whether the site runs JavaScripts at all, by inserting the following somewhere in the page's <body>:

Code: Select all

<script type="text/javascript" language="JavaScript">
<!-- document.write(navigator.appName); //--></script>


The script should have shown the user's browser, but the script just didn't work! It was however present in the source code, but there was no output, and no error message (not even when I omitted the <!-- and //--> tags). It seems as though the scripts are not processed by IE6 anymore.

Is this a configuration setting or something? I don't have a clue as to why don't the scripts work when the site is processed through Apache.

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Sat Apr 10, 2004 2:51 am

Well it works fine with me!
Let´s just do some changes to see what happens!

Use javascript: before function name when you call it, like:

Code: Select all

onclick="javascript:word_open('...'); return false;"

And try to use the name property of <a> tag instead of target. And you don´t need the href property:

Code: Select all

<a name="word" onclick="javascript:word_open('...'); return false;" class="blue">consectetuer adipiscing</a>


Try it ;)

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Sat Apr 10, 2004 5:48 am

Actually, gesf, you don't use the javascript: keyword inside onclick attributes. You only use if it you want javascript in the href.

User avatar
maurits
New php-forum User
New php-forum User
Posts: 31
Joined: Fri Mar 26, 2004 3:27 pm
Location: Eindhoven, The Netherlands

Postby maurits » Sat Apr 10, 2004 6:20 am

Hi Gesf!

Thanks for your help, but I know that the script works already, because I tried to run it as *.html file from my desktop, instead of rendering it through Apache.

It's not this script that doesn't work in particular. None of the Javascripts work at all. That is why I didn't post any source code in the beginning. It doesn't matter what kind of activity I want the script to do, the browser just ignores any Javascript that is rendered through Apache, not even when it is a plain *.html file on the Apache server, instead of a PHP file. Whereas if I was to run the very same page directly from my hard drive, it does work. :shock:

I thought it could perhaps be a configuration setting in Apache, although I would think that is very unlikely because it is client side, and not server side.

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Sat Apr 10, 2004 6:47 am

This is really bizarre. My only guess is that somehow your browser's security settings got changed to ignore JavaScript from localhost. See if it works in a different browser.

User avatar
maurits
New php-forum User
New php-forum User
Posts: 31
Joined: Fri Mar 26, 2004 3:27 pm
Location: Eindhoven, The Netherlands

Postby maurits » Sat Apr 10, 2004 7:19 am

Swirlee, I have one word for you:

Brilliant!

It were indeed the security settings in my browser! :shock:

I feel very ashamed having troubled you guys with this problem, please accept my humble apologies. Sometimes one just needs somebody like Columbus (egg story - lol) to solve a problem as simple as mine. Thank you very much!

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Sat Apr 10, 2004 8:56 am

swirlee wrote:Actually, gesf, you don't use the javascript: keyword inside onclick attributes. You only use if it you want javascript in the href.
Yeh... now i know :P


Return to “PHP Installation”

Who is online

Users browsing this forum: No registered users and 1 guest

cron