Forum Moderators: open

Message Too Old, No Replies

Javascript Problem with IE but not Opera or Firefox

Anyone got a clue about this problem?

         

JerryOdom

12:52 am on May 19, 2006 (gmt 0)

10+ Year Member



I have a page with a select box that calls a function via the onchange event. The function is called from a script src tag that is in the <head>.

When you go to the page and use the select box it throws an "Object Expected" error in IE. It works fine in Opera and Firefox. In IE it'll only work if I refresh the page.

It acts like its not loading the external js on the first try? I use the absolute path to the javascript. No errors in the Firefox console or Opera that I can detect.

Ring any bells to anyone?

Rambo Tribble

1:35 am on May 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Usually the error in question occurs when you try to run a script on a page that hasn't built yet. Any functions that modify page elements should be called after the page has loaded, by using window.onload=function_name

JerryOdom

3:09 am on May 19, 2006 (gmt 0)

10+ Year Member



The function does change the page but the change is triggered by the onchange being called via use of the select box. Thats after the page has loaded.(or has supposedly been loaded) Could something be stopping the page from loading completely?

milanmk

4:16 am on May 19, 2006 (gmt 0)

10+ Year Member



Rambo Tribble is right and if you dont mind posting your script code than we can help you further.

Milan

kaled

10:03 am on May 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The <head> is a tidy place to put scripts. Directly before the </body> (i.e. the end of the document) is often more sensible.

Kaled.

JerryOdom

5:30 pm on May 19, 2006 (gmt 0)

10+ Year Member



Hey guys thanks for responding to help. I've put the script src at the bottom of the page and it makes no difference.

I can't post the code as its pretty large and other than not functioning properly error free but if anyone wants to see it let me know and I'll show you the page.

Here is a little more info though. The code works if the debugger is off in IE.

The problem is that when you first go to a page with this script src tag its not loading the page. I don't know if this is due to some sort of strange cache but the script is not re-loaded unless you hit the reload button. But I put an alert inside the script.js file and it is called when the debugger is off everytime like its supposed to be. Turn the debugger on and you don't get an alert because the page isn't loaded. anyone?

Rambo Tribble

10:25 pm on May 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let me make sure I understand you correctly: It is a .js file in script tag with an src value that is not loading correctly? Is the .js file server-script generated, or a static file? Does an absolute vs. relative URL make any difference?