| Author |
Firefox unable to detect the javascript on onload event
|
Rizwan Patel
Ranch Hand
Joined: Jan 03, 2008
Posts: 59
|
|
Hi Ranchers,
I am facing the problem in Firefox version 3.0.6 it was working fine till Firefox version 3.0.3 as well as other browsers such as IE5,6,7 and Flock
Scenario :
Web page loads successfully first time. Then, redirected to the alert message box. While returning back from the alert message box which is having only one button OK. The parent page goes blank.
I had written the javascript function which needs to be called on onload event of the page. This function is successfully invoked in all other browsers except the Firefox 3.0.6.
But, when I had explicitly put an alert message in the javascript function then it is working fine!
Totally confused about the behaviour of the browsers.
Is there any way to sort the above problem.
Please refer the below code snippet
When look in the Error Console of the firefox it displays the onLoadWindow() not defined.
If it was not defined then how come the IE and FLOCK refer and display the page correctly?
Please help totally messed up....! Because the same is working in the lower version of Firefox!
|
scjp 1.5, OCPJWSD 5
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
You need quotes around it
Better to use the following in your script tag
Eric
|
 |
Rizwan Patel
Ranch Hand
Joined: Jan 03, 2008
Posts: 59
|
|
Hi Eric,
I have given the double quotes around the function call! Then also it did not working.
|
 |
Saifuddin Merchant
Ranch Hand
Joined: Feb 08, 2009
Posts: 576
|
|
The code looks fine to me except for the strange looking alert alert(\n\"HI\"\n)"); why are the quotes so weird and whats with the extra brackets? There is no way this could work on any browser
What works fine for me (Firefox 3.0.6) is
Of course putting inline java script code is considered pretty bad practice, but I don't think firefox should be stopping you. The problem you getting is almost associated with something else being wrong in your code. Probably you need to post you actual code, if you still face the problem.
|
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
|
 |
Rizwan Patel
Ranch Hand
Joined: Jan 03, 2008
Posts: 59
|
|
Thank you for the Reply,
Now I have modify the code as par the suggestion missing quotes in alert box.
It works fine for some time and after two three attempts means refreshing the page,the error console displays the same error method not defined.
Not solved. I had check the source code again and found that method is present.
Is there any property which we need to handle propertly? in firefox!
|
 |
Saifuddin Merchant
Ranch Hand
Joined: Feb 08, 2009
Posts: 576
|
|
I tried out the code too and it works fine for me (actually its elementary Java Script and should work anyways).
More ever the code working fine a couple of time and then not working is pretty strange behavior for Java Script (well unless Ajax is involved! Then it starts to get complicated )
Can you post the exact source code that you are trying out?
Also can you give a screen shot or exact posting of the error it shows in console? BTW (by the way) which console are you talking about - are you using firebug?
|
 |
Rizwan Patel
Ranch Hand
Joined: Jan 03, 2008
Posts: 59
|
|
Error console in Firefox browser -> Tools -> Error Console
Yes I have checked in Firebug also but the same problem? It displays the method undefined
|
 |
Saifuddin Merchant
Ranch Hand
Joined: Feb 08, 2009
Posts: 576
|
|
|
Works fine for me. No Errors in the FireFox Error Console or Firebug ...
|
 |
 |
|
|
subject: Firefox unable to detect the javascript on onload event
|
|
|