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



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?
Of course! My apologies...

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

<script type="text/javascript" language="JavaScript">


<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" />

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

<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>:

<script type="text/javascript" language="JavaScript">

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 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.
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:
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:
<a name="word" onclick="javascript:word_open('...'); return false;" class="blue">consectetuer adipiscing</a>

Try it ;)
Actually, gesf, you don't use the javascript: keyword inside onclick attributes. You only use if it you want javascript in the href.
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.
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.
Swirlee, I have one word for you:


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!
swirlee said:
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