Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamicaly opening a window works in FF, not in IE...

Status
Not open for further replies.

Roel018

Programmer
Jun 12, 2002
30
NL
Hi folks,

This function works great in FF, but in IE i get a runtime error on line 16 javascript error.... I don't get why..

=====================================================
<script language="JavaScript"><!--
function newWindow(imagename, text) {

var newVar = imagename + "xxxxxx" + text;

msgWindow=open('imagepopup.asp',newVar,'resizable=no,width=650,height=570,scrollbars=yes');
if (msgWindow.opener == null) msgWindow.opener = self;
}
//--></script>
=====================================================

For example, I target this function using this link:
javascript:newWindow(document.getElementById("image5").src, "text description")

Hope anyone know what's wrong.. Line 16 is the line 'msgWindow.... etc.'.

Regards,
roel
 
You cannot pass in a space in the second parameter to the window.open command. The error you see is happening because you have a space in the string "text description". Remove the space and you will be fine.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
To:eek:p
I would say there is a frustrating, and angryable, bug introduced at certain moment in more recent versions including v.6 of ie of an as major a functionality as window.open method in both aspects of [1] capturing the custom defined name of the window and of [2] re-use of the same window.

This is a work-around I would propose for ie-moz "cross-browser" scripting.
[tt]
var msgWindow = new Object(); //or at least msgWindow being global uninitiated, I suppose
function newWindow(imagename, text) {
var newVar = imagename + "xxxxxx" + text;
if (msgWindow && msgWindow.name==newVar && !msgWindow.closed) {
msgWindow.location="imagepopup.asp";
} else {
msgWindow=open('imagepopup.asp','','resizable=no,width=650,height=570,scrollbars=yes');
msgWindow.name=newVar;
}
//the following I use your line without looking into its repercusions
if (msgWindow.opener == null) msgWindow.opener = self;
}
[/tt]
 
Thnx fellaz, I got it to work thanks to your help !!!!! The above code worked with a little adjustment, just perfectly !

Thnx again !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top