> Programming Languages > Javascript
Various Topics Home | Disclaimer | Report Adult Posts

Various Topics on Javascript



Javascript - "IE problem with open.window" in Programming Languages


Old 04-07-2004   #1
.... ..i..
 
Default IE problem with open.window

I am quite new to javascript, and don't seem to find the problem with
stupid internet explorer.
The script works fine in safari and mozilla.
I searched the groups, but evidently put in the wrong keywords, didn't
find the solution.
It seems to be as easy as it gets: open a new window with a new url.
in IE (I am using IE in mac osx), the error message is:

Microsoft JScript runtime error:
Line: 9
Char: 8
Error: Type mismatch

Thanks for any tips! I am getting crazy over this!
q.

here are the scripts:

test.js:
function launchDisplay(mydata) {
datasetWindow=window.open("describe_data.cgi" + mydata, " ",
"width=500,height=200,scrollbars=yes, resizable=yes")
}

test.html:
<head><title>Untitled Do***ent</title>
<script language="JavaScript" src="test.js"
type="text/javascript"></script>
</head><body><a HREF="#" onC****="launchDisplay('?dataset=mydataset');
return false;">Display Properties of selected Dataset</a>
<br />
</body>
</html>
 
Old 04-08-2004   #2
..
 
Default Re: IE problem with open.window

Anna Quick wrote:

> I am quite new to javascript, and don't seem to find the problem with
> stupid internet explorer.
> The script works fine in safari and mozilla.
> I searched the groups, but evidently put in the wrong keywords, didn't
> find the solution.
> It seems to be as easy as it gets: open a new window with a new url.
> in IE (I am using IE in mac osx)


IE for Mac OS X is a rare bird.

, the error message is:
>
> Microsoft JScript runtime error:
> Line: 9
> Char: 8
> Error: Type mismatch
>
> Thanks for any tips! I am getting crazy over this!
> q.
>
> here are the scripts:
>
> test.js:
> function launchDisplay(mydata) {
> datasetWindow=window.open("describe_data.cgi" + mydata, " ",
> "width=500,height=200,scrollbars=yes, resizable=yes")


Avoid an empty string for the window name. Avoid blank space in the 3rd
parameter of the window.open (in the windowFeatures string list): this
is an error for Netscape browsers.

> }
>
> test.html:
> <head><title>Untitled Do***ent</title>
> <script language="JavaScript" src="test.js"


language is deprecated while type is both backward and forward-compatible.

> type="text/javascript"></script>
> </head><body><a HREF="#" onC****="launchDisplay('?dataset=mydataset');


The problem with this is that nothing happens (no do***ent, no content
at all) if javascript support is disabled. About 8-12% of users have
javascript disabled. Your code here is not robust, not promoting
accessibility to content.

> return false;">Display Properties of selected Dataset</a>



Try this:

In your html:
-------------
<a href="describe_data.cgi?dataset=mydataset" target="RequestedPopup"
onc****="launchDisplay(this.href, this.target); return false;"
title="C****ing this link will create a new window or will reuse an
already opened window">Display Properties of selected Dataset <img
src="http://www10.brinkster.com/doctorunclear/GRAPHICS/PNG/OpenRequestedPopup.png"
width="25" height="25" alt="[will create a new window]"></a>

In your <script> in your <head>:
--------------------------------

<script type="text/javascript">
var WindowObjectReference, strPreviousURL;
function launchDisplay(strCurrentURL, strTarget)
{
if(WindowObjectReference == null || WindowObjectReference.closed)
{
WindowObjectReference = window.open(strCurrentURL, strTarget,
"width=500,height=200,resizable,scrollbars,status" );
}
else if(strPreviousURL != strCurrentURL)
{
WindowObjectReference = window.open(strCurrentURL, strTarget,
"width=500,height=200,resizable,scrollbars,status" );
WindowObjectReference.focus();
}
else
{
WindowObjectReference.focus();
};
strPreviousURL = strCurrentURL;
}
</script>

You can furthermore develop the accessibility, usability ideas of such
script with cursor styling and make the new window coordinate positions
and dimensions entirely scalable, proportional to the user's browser
viewport.

DU
 

Thread Tools
Display Modes





Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0