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