473,513 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opera 7.54 Javascript Errors

I've got a linked 'common.js' file that contains one function, on IE
and Firefox everything works as expected. However, Opera generates the
following error:
http://www.mdocs.ca/scripts/common.js
Unknown context
Syntax error while loading (line 61)

-^
line 61 is the close } of the function?

Now I'm not sure if this is related to my other problem, but when I
click the Opera Test link (to create the popup) it generates this
error:
http://www.mdocs.ca/alpha_v1d814.htm
Javascript URL thread:
"javascript:popupWindow('http://www.mdocs.ca/feedback.htm','feedback',460,415,0,0,'yes','no','n o','n..."
Error:
name: ReferenceError
message: Statement on line 1: Reference to undefined variable: No such
variable 'popupWindow'
Backtrace:
In unknown script
popupWindow("http://www.mdocs.ca/feedback.htm", "feedback", 460,
415, 0, 0, "yes", "no", "no", "no");
It says that it can't reference the variable 'popupWindow' when in
fact, its a function that is defined in the linked common.js file.
Any ideas?

Cheers!
M.

Jul 23 '05 #1
6 1942
On 14 Aug 2004 21:16:37 -0700, Mark Pappert <pa******@hotmail.com> wrote:
I've got a linked 'common.js' file that contains one function, on IE
and Firefox everything works as expected. However, Opera generates the
following error:
http://www.mdocs.ca/scripts/common.js
Unknown context
Syntax error while loading (line 61)

-^
line 61 is the close } of the function?
<!-- mdocs.ca Common Scripts v0.1 | Copyright (c) 2004, Immergis
Corporation. All Rights Reserved -->

I'm curious to know why you're using SGML comments in a JavaScript file.
Use SGML delimiters in HTML and

// Single line
/* or
Multi-line */

comments in scripts. Removing the final SGML comment, or replacing it with
an equivalent script comment allows the script to run, but *ALL* of them
should be replaced.
Now I'm not sure if this is related to my other problem, but when I
click the Opera Test link (to create the popup) it generates this
error:


If the script doesn't load properly, why would the function load properly?
Of course, it doesn't help that you have more inappropriate comment types
within the function, too.

[snip]

Now to the rest of the script...

resizable[ optional; value = yes|(no) ]

Am I to assume that your notation implies the resizable option defaults to
"no"? If so, it shouldn't. There is no reason why you should restrict the
users ability to resize the window. For one, unless your specifying exact
sizes (which you shouldn't), you can't tell how large the users browser
text will be and whether that will cause the content to be too big for
your window. There's another (not so significant) reason that I'll come to
later.

At least the scrollbars default to 'yes', however I notice that you
disable them in the call. Again: don't!

isIE = new Boolean(false);

Simply

isIE = false;

will to, however

if (navigator.userAgent.indexOf("MSIE")!=-1) { isIE = true; }
if (navigator.userAgent.indexOf("Opera")!=-1) { isIE = false; }

is nonsense. You cannot reliably detect the browser in use based upon the
userAgent string. Most browsers, even IE, can have it set to whatever the
user wants, and there are plenty of browsers that fake other major browser
types.

if (isIE == true) {

It is simpler to write

if(isIE) {

<!-- COMMENT[MP]: Adjust Width/Height to Reflect that IE Measures
Window Size and not Inner Size -->
width = width + 6; height = height + 32

<!-- COMMENT[MP]: Adjust Window Size to Account for for WinXP|SP2;
If Status is 'NO' -->
if ((navigator.userAgent.indexOf("SV1")!=-1) && (status = 'no'))
{ height = height + 20; }

More nonsense; both the comment types and the code. Your adjustments are
based upon the assumption that every Windows system in the world is the
same as yours. It isn't. The size of the title bar, borders, status bar -
in fact, virtually every component - varies according the to applied
theme. The only way you can determine the actual sizes is through a direct
call to the Win32 API, which you obviously can't do from within a script.

This is the other reason that I mentioned above regarding sizing. If your
estimates are completely wrong, and they could be, you'll be creating a
window too small for the content, with no way to resize or scroll.

win = window.showModelessDialog(sURL,sArguments,sFeature s);

That's all you should really need to test for. If the browser supports
showModelessDialog(), it should support everything you've done to
configure the call. So, change

if (isIE == true) {

to

if(window.showModelessDialog) {

to get a more reliable idea of what the browser can do. This is called
feature testing: check that the properties and methods you want to execute
are available, and use them if they are. The group FAQ can tell you more.

winLeft = (screen.availWidth - width) / 2;
winTop = (screen.availHeight - height) /2;

What if the user has multiple monitors?

Of course, why you need those contact pages in another window is another
fine question. They will do just as well presented as normal pages.

In a world where the number of pop-up blockers, both conservative and
indescriminate, are growing every day, opening new windows (thought
annoying enough anyway) is a bad idea.

Finally, you ought to review the group FAQ regarding JavaScript links.
They make a site dependent for no good reason, cause various other
(unrelated) problems, and should be avoided in all but a few cases.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail
Jul 23 '05 #2
Ivo
"Mark Pappert" wrote
I've got a linked 'common.js' file that contains one function, on IE
and Firefox everything works as expected. However, Opera generates the
following error:
http://www.mdocs.ca/scripts/common.js
Unknown context
Syntax error while loading (line 61)

-^
line 61 is the close } of the function?
Remove the SGML comments from the .js file.
This is a SGML comment:
<!-- All Rights Reserved -->

But a javascript comment looks like this:
// All Rights Reserved

or this:
/* All Rights Reserved */

After you have cleaned up the file, you may want to run it through the
javascript lint at http://www.crockford.com/javascript/jslint.html to check
for other problems.

Now I'm not sure if this is related to my other problem, but when I
click the Opera Test link (to create the popup) it generates this
error:
http://www.mdocs.ca/alpha_v1d814.htm
Javascript URL thread:
"javascript:popupWindow('http://www.mdocs.ca/feedback.htm','feedback',460,41
5,0,0,'yes','no','no','n..." Error:
name: ReferenceError
message: Statement on line 1: Reference to undefined variable: No such
variable 'popupWindow'


Of course not. Poor Opera hasn't understood a single letter from your .js
file.
Also putting javascript in the href of a link is usually not a good idea.
See the FAQ.
<URL: http://jibbering.com/faq >
Jul 23 '05 #3
JRS: In article <opscrgyacgx13kvk@atlantis>, dated Sun, 15 Aug 2004
06:41:40, seen in news:comp.lang.javascript, Michael Winter <M.Winter@bl
ueyonder.co.invalid> posted :

Finally, you ought to review the group FAQ regarding JavaScript links.
They make a site dependent for no good reason, cause various other
(unrelated) problems, and should be avoided in all but a few cases.

Does that mean that <a href="javascript:testF()">Test</a> is
deprecated (testF being a function)?

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4
Dr John Stockton wrote:
JRS: In article <opscrgyacgx13kvk@atlantis>, dated Sun, 15 Aug 2004
06:41:40, seen in news:comp.lang.javascript, Michael Winter <M.Winter@bl
ueyonder.co.invalid> posted :
Finally, you ought to review the group FAQ regarding JavaScript links.
They make a site dependent for no good reason, cause various other
(unrelated) problems, and should be avoided in all but a few cases.


Does that mean that <a href="javascript:testF()">Test</a> is
deprecated (testF being a function)?


Its not so much that its deprecated, it creates a javascript dependency
and is known to cause problems with animated gifs.

Both issues can be solved by:

<a href="jsDependency.html" onclick="testF();return false">Test it</a>

Where jsDependency.html can be a page that explains the test, maybe even
provide the function details.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #5
Dr John Stockton <sp**@merlyn.demon.co.uk> writes:
Does that mean that <a href="javascript:testF()">Test</a> is
deprecated (testF being a function)?


If the function returns "undefined", that is, the URL is only used
for its side effect, and not as a way to create a replacement for
the current page, then it should be deprecated. It is misuse of the
"a" tag, since the URL doesn't refer to another page.

Instead, one could (and should) use:
<input type="button" value="Test" onclick="testF()">
Buttons are meant to have an effect when pressed. Links are meant
to lead to another resource. If, for some reason, using a button
is not acceptable, then at least using
<a href="youNeedJS.html" onclick="testF();return false;">Test</a>
is better, since it gives a default behavior if Javascript is
disabled (even if that behavior is just to lead to a page that
explains that Javascript is required)
If "testF" actually returns the HTML of a new page, then the
"javascript:" scheme URL is used correctly. However, it still has no
reasonable behavior if Javascript is not available, and should be
avoided for that reason alone.
It's not officially deprecated (since it was never officially defined
anyway), but I'd recommend against it when used on the internet (where
~10% are surfing without Javascript according to some statistics, although
that number seems to be dropping).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #6
JRS: In article <br**********@hotpop.com>, dated Mon, 16 Aug 2004
02:24:41, seen in news:comp.lang.javascript, Lasse Reichstein Nielsen
<lr*@hotpop.com> posted :
Dr John Stockton <sp**@merlyn.demon.co.uk> writes:
Does that mean that <a href="javascript:testF()">Test</a> is
deprecated (testF being a function)?
If the function returns "undefined", that is, the URL is only used
for its side effect, and not as a way to create a replacement for
the current page, then it should be deprecated. It is misuse of the
"a" tag, since the URL doesn't refer to another page.


It has no return statement, the function being used for side-effect.

If "testF" actually returns the HTML of a new page, then the
"javascript:" scheme URL is used correctly. However, it still has no
reasonable behavior if Javascript is not available, and should be
avoided for that reason alone.


It's reasonable to expect that javascript is available to the reader of
that page, whether or not it is currently operational, since the
document in question describes itself, more or less, as a javascript
FAQ. Not, of course, the JL/RC one.
Perhaps Martin would be the best person to look into improving that FAQ,
which also has an ingenious, but unsymmetrical, rounding-to-decimal-
string routine.

There's a certain charm in a FAQ which, in referring to presenting a
lastModified date in the usual local form, chooses Jan 1st for an
example - no, it's worse than that, it shows the actual live string, and
the page was edited on Jan 1st. A fresh local copy shows me
(unconverted)
document.lastModified: 08/16/04 21:40:24
I tried Tidy on it; and, for comparison, on our FAQ. Early in our sec
2.3, it objects to the space before http:// ; it likes theirs less.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2323
by: Spijon | last post by:
Seems opera can not work normally with javascript, does anyone knows how to fix it? Thanks in advance.
2
1988
by: roman | last post by:
Hello, I've just downloaded and installed Opera711, good browser. Most of my scripts work just fine, except the ones that use "clip" property. Opera docs say that it's supported but I can't get...
5
6363
by: Dan Tartakovsky | last post by:
Hi, folks. Does this error below look familiar to you? I'm trying to access function in one frame from the other frame. Error is received while working with Opera or Netscape (different errors)....
3
1655
by: Michael Phillips | last post by:
Hello I am trying to use DOM to create an object in a document and wish to be compativle with Opera My code is containerDiv = document.createElement("div"); //create download container...
6
2701
by: Shaun Fleming | last post by:
I've been trying to make this simple script compatible across various browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I have version 7.11). This is what is supposed to happen:...
2
1548
by: Jeff Thies | last post by:
How do you view javascript errors in Opera? IE pops them in a modal box and NS has the excellent javascript console. What does Opera have? Jeff
6
6649
by: Stefan Mueller | last post by:
After my web page has been loaded I'm doing some tests with a JavaScript. If I figure out that something is wrong I'd like to reload the whole frameset. With Internet Explorer and Mozilla Firefox...
3
1267
by: Crazy Code Ninja | last post by:
Hi, I created a page with xhtml 1.0 transitional dtd, its validated correctly, but now the javascript wouldn't work under Opera (version 8.5 I think). It works under firefox. My code is as...
5
1306
by: Dr J R Stockton | last post by:
Computed at <URL:http://www.merlyn.demon.co.uk/js-datex.htm#OSTby the code shown above it when using Opera 9.24 : Test exact dates in two 11-year ranges; IE & FF are OK. Opera 9.24 shows...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.