views:

52

answers:

5

I have this code:

  <body onLoad="subcatSelection();">

The function is inside a .js file which is included with this code:

  <script type="text/javascript" src="bincgi/search_lists.js"></script>

The function contains an alert('hello'); just for testing purposes to see if it gets called, but it doesn't.

The "Page error" or whatever its called on the bottom left corner of Explorer 6 is displayed and when double clicking it it assumes there is an error on LINE x ROW y, which is the body-onload event.

Anybody has an ide?

If you need more input let me know... Thanks

UPDATE:

Some html before the onload event...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="bincgi/search_lists.js"></script>
<script type="text/javascript" src="bincgi/jsfunctions.js"></script>
<script type="text/javascript" src="bincgi/calendar_eu.js"></script>
<link href="bincgi/main_styles.css" rel="stylesheet" type="text/css">
<link href="bincgi/calendar.css" rel="stylesheet" type="text/css">
<!--[if lt IE 8]>
<link href="bincgi/main_styles_ie_lt7.css" rel="stylesheet" type="text/css">
<![endif]-->

<style type="text/css">
body {
    background-color: #fffec7;
    background-image: url(Graphics/test_bgr.gif);
    background-repeat: repeat-x;
}
</style>

</head>
<body onLoad="subcatSelection();">
A: 

As far as I see from the comments, the problem might be in the other line of search_lists.js (that might be before subcatSelection definition). IE just stops parsing it and doesn't load the function correctly. Try to leave a single function definition in that file and see what happens:

function subcatSelection() {
    alert ("Hello");
}
Juriy
Just tried it and didn't work... It is like the file doesn't get called at all...
Camran
check update...
Camran
Ok. Try to just point your browser to that file. That's the last version that I can imagine :-) Also try to launch it in FF or other browser to see if problem reproduces. In any case you should minimize your test case to remove any possible problems
Juriy
A: 

It may be possible that there's a syntax error that it is avoiding the correct definition of the function. Make that function the only function in your .js file, put your test alert("hello!), and try again.

luiscolorado
http://jslint.org
mike clagg
A: 

Check the permissions, you are running inside a cgi bin folder which operates a bit different

I would also suggest not mixing your js files with your CGI (who uses cgi anymore)

mike clagg
this is on a local machine... virtual server etc...
Camran
+1  A: 

If [Juriy] answer didn't work, then try calling your function in your page:

<script type="text/javascript" src="bincgi/search_lists.js"></script>
<script type="text/javascript" >
    alert("first test");
    subcatSelection();
</script>

If that doesn't work, it has to be a trivial problem (e.g., file in wrong location, need to re-start browser, clean cache, etc.)) that is giving you troube.

luiscolorado
ok thanks... I have tried it now and the alert box shows, but the function isn't called... thanks
Camran
A: 

Because you have the problem on IE6 only from what I understand, I would try to first use Fiddler to determine if your file is downloaded correctly, if it is then I would modify the content of search_list.js to be:

alert('Before def');
function subcatSelection() {
    alert('In subcatSelection');

}
alert('After def');

Then create a page like this to see if you get the alerts in that order: 'Before def', 'After def', 'Before Call', 'In subcatSelection', 'After Call'.

At that point, you should know for sure where is the problem if it's still there. If you don't have the error, then start plugging back the pieces one by one (move the call in body onload then try, re-add the code in search_list.js then try, re-add the other JS includes then try, etc.)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="bincgi/search_lists.js"></script>
<script type="text/javascript">
    alert("Before Call");
    subcatSelection();
    alert("After Call");
</script>
</head>
<body>test</body></html>
SBUJOLD