| | |
Opera Javascript bug? (works in Firefox)
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2007
Posts: 2
Reputation:
Solved Threads: 0
All,
I am currently developing a UserJS "plug-in" for Opera in Linux using verision 9.21, build 641. I have encountered some bizarre problems and have been able to isolate and reproduce one using the code posted below. The basic issue throughout my code (and reproduced below) is that a command may either not execute, may execute incorrectly, or may execute differently depending on whether or not an alert() precedes it. Using Firefox, preceding the alert(hidden.contentDocument) command with another alert does not change anything (as well it shouldn't).
Has anyone else encountered this or have any suggestions? I cannot afford to have random alerts throughout my code (obviously).
Thanks in advance!
Louis
I am currently developing a UserJS "plug-in" for Opera in Linux using verision 9.21, build 641. I have encountered some bizarre problems and have been able to isolate and reproduce one using the code posted below. The basic issue throughout my code (and reproduced below) is that a command may either not execute, may execute incorrectly, or may execute differently depending on whether or not an alert() precedes it. Using Firefox, preceding the alert(hidden.contentDocument) command with another alert does not change anything (as well it shouldn't).
Has anyone else encountered this or have any suggestions? I cannot afford to have random alerts throughout my code (obviously).
Thanks in advance!
Louis
javascript Syntax (Toggle Plain Text)
<html> <body> <script type="text/javascript"> var hidden = document.createElement('iframe'); hidden.src = "http://www.opera.com"; hidden.id = "iframe" document.body.appendChild(hidden); // if the below alert is commented out, the alert(hidden.contentDocument) command displays an alert box saying "null". // if the below alert is not commented out, the alert(hidden.contentDocument) command displays an alert box saying "[object HTMLDocument]". //alert("stuff") alert(hidden.contentDocument) </script> </body> </html>
Where is the semicolon that belongs after each alert statement? You have a run-on statement.
The next statement is not executed because the semicolon is missing. The interpreter thinks the statement is not over yet. It then finds it doesn't know what to do with the improper code it finds, and skips to the next semicolon.
Some interpreters incorrectly ignore missing semicolons when it is "obvious" that a new statement has been started. They should not do that. And you should never count on it happening.
The next statement is not executed because the semicolon is missing. The interpreter thinks the statement is not over yet. It then finds it doesn't know what to do with the improper code it finds, and skips to the next semicolon.
Some interpreters incorrectly ignore missing semicolons when it is "obvious" that a new statement has been started. They should not do that. And you should never count on it happening.
Last edited by MidiMagic; Jun 28th, 2007 at 7:12 pm. Reason: sin tax
Daylight-saving time uses more gasoline
That's a difference between Java and JavaScript.
Actually, there are certain places in JavaScript where semicolons are required (between statements), some places where they are optional (before a close brace), and some places where they are prohibited (before an else).
Actually, there are certain places in JavaScript where semicolons are required (between statements), some places where they are optional (before a close brace), and some places where they are prohibited (before an else).
Last edited by MidiMagic; Jun 29th, 2007 at 1:37 am.
Daylight-saving time uses more gasoline
> Actually, there are certain places in JavaScript where semicolons are required
Here you are talking about the syntax (for example the for loop) which mandates semicolon be placed. In Javascript as long as statements are separated by whitespaces (newlines) it shouldn't be a problem, though older / non-complaint browsers balk at it.
Here you are talking about the syntax (for example the for loop) which mandates semicolon be placed. In Javascript as long as statements are separated by whitespaces (newlines) it shouldn't be a problem, though older / non-complaint browsers balk at it.
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- IE7 New Window Javascript (JavaScript / DHTML / AJAX)
- Javascript and Firefox ISSUES (JavaScript / DHTML / AJAX)
- Javascript problem in FIREFOX (JavaScript / DHTML / AJAX)
- script works in Opera but not Firefox (Python)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Registration of ocx file from server
- Next Thread: help needed in coloring html tables
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column createrange() css cursor date debugger dependent disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math media microsoft mimic object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post problem programming progressbar regex runtime scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






