Problem with javascript command window.open()

NEW
Unassigned

Status

()

Core
DOM: Core & HTML
15 years ago
8 years ago

People

(Reporter: Peter Rosenberg, Unassigned)

Tracking

Trunk
x86
Windows 98
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

15 years ago
Hi

I added the code of a html-document to this message. This html-document works 
fine with IE 6.x. The document shows a short list. Its possible to select an 
item from this list (mouseclick). Afterwards I want to open a new window. It 
works with the IE 6.x but with NS I always get an error in the debugger-window:

Error: uncaught exception: [Exception... "Component returned failure code: 
0x80004005 (NS_ERROR_FAILURE) [nsIDOMJSWindow.open]"  nsresult: "0x80004005 
(NS_ERROR_FAILURE)"  location: "JS frame :: file:///D:/temp/document.htm :: 
action :: line 49"  data: no]

I have no idea to solve this problem. In my sample code you can search the word 
Problem then you will find the part of the code whitch will not work. If you 
use the command alert('hi there'); then everything it's okay. If you use the 
command window.open() at this position then you always get an error in the 
error browser and you can see no action in the normal browser-window.

Please help. I dont understand that. It works in the IE 6.0 but I want to use 
NS! :-)

Here the code of the document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 
4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="DC.Rights" content="Copyright (C) Peter Rosenberg, Beinwil bei Muri 
(Aargau), Switzerland"><title>business_instruments</title>

<script type="text/javascript">

<!--

	// Copyright (c) Peter Rosenberg, Switzerland
	// Default values
	var window_x = 100;
  var window_y = 50;
  var window_width = 600;
  var window_height = 400;
  var htmString_Blank 
= "<html><head><title>bds@Net</title></head><body></body></html>";
  var htmString_Header = htmString_Blank;
  var htmString_Left = htmString_Blank;
  var htmString_Main = htmString_Blank;
  var htmString_Control = htmString_Blank;
  var htmString_Footer = htmString_Blank;
  var htmString_TopLeft = htmString_Blank;
  var htmString_BottomLeft = htmString_Blank;
	var htmString_rowBackgroundColorNormal = "#FFFFFF";
	var htmString_rowBackgroundColorFocus = "#CADFE6";
	var vMode;
	var vWindowClose;
	var vWindowNew;
	var vWindowHref;
	var vWindowName;
	var vWindowParameters;
	var vIdValue;

	//Needed tags to insert code
	htmString_Main='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 
4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html>\n<head>\n<meta http-
equiv="content-type" content="text/html; charset=ISO-8859-1">\n<meta 
name="DC.Rights" content="Copyright (C) Peter Rosenberg, Beinwil bei Muri 
(Aargau), Switzerland">\n<style type="text/css">\nbody {font:normal 10pt Arial; 
border:0px; margin:0px}\ntable {border:0px; table-layout:auto; border-
collapse:collapse; empty-cells:show; font:normal 10pt Arial; cursor:default;}
\ntd {border:1px solid #CCCCCC; padding-left:2px; padding-right:2px; padding-
top:1px; padding-bottom:1px;}\n</style>\n</head>\n<body>\n<TABLE 
style="width:400px"></tr>\n<tr id=1 onClick="javascript:parent.action(\'1\',\'0
\',\'0\',\'bds_blu_userManagement.php?
fn=usersDelete&sp=userDelete\',\'newwindow\',\'depend=yes,menubar=no,height=180,
width=300\',\'1\');" onMouseover="javascript:parent.rowMark(1,1);" 
onMouseout="javascript:parent.rowMark(0,1);">\n<td style="width:200px; white-
space:nowrap; text-align:left;">System</td>\n<td style="width:170px; white-
space:nowrap; text-align:left;">10a8de3b23a64668</td>\n</tr>\n<tr id=2 
onClick="javascript:parent.action(\'1\',\'0\',\'0
\',\'bds_blu_userManagement.php?
fn=usersDelete&sp=userDelete\',\'newwindow\',\'depend=yes,menubar=no,height=180,
width=300\',\'5\');" onMouseover="javascript:parent.rowMark(1,2);" 
onMouseout="javascript:parent.rowMark(0,2);">\n<td style="width:200px; white-
space:nowrap; text-align:left;">Sysop</td>\n<td style="width:170px; white-
space:nowrap; text-
align:left;">091d5231638149e9</td>\n</tr>\n</table>\n</body>\n</html>\n';htmStri
ng_Left='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 
4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html>\n<head>\n<meta http-
equiv="content-type" content="text/html; charset=ISO-8859-1">\n<meta 
name="DC.Rights" content="Copyright (C) Peter Rosenberg, Beinwil bei Muri 
(Aargau), Switzerland">\n<style type="text/css">\nbody {font:normal 10pt Arial; 
border:0px; margin:0px}\ntable {border:0px; table-layout:auto; border-
collapse:collapse; empty-cells:show; font:normal 10pt Arial; cursor:default;}
\ntd {border:1px solid #CCCCCC; padding-left:2px; padding-right:2px; padding-
top:1px; padding-bottom:1px;}\n</style>\n</head>\n<body>\n<table>\n</tr>\n<tr 
id=1 onClick="javascript:parent.action();" 
onMouseover="javascript:parent.rowMark(1,1);" 
onMouseout="javascript:parent.rowMark(0,1);">\n<td style="width:30px; white-
space:nowrap; text-align:right;">1</td>\n</tr>\n<tr id=2 
onClick="javascript:parent.action();" onMouseover="javascript:parent.rowMark
(1,2);" onMouseout="javascript:parent.rowMark(0,2);">\n<td style="width:30px; 
white-space:nowrap; text-
align:right;">5</td>\n</tr>\n</table>\n<br><br><br></body>\n</html>\n';htmString
_Header='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 
4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html>\n<head>\n<meta http-
equiv="content-type" content="text/html; charset=ISO-8859-1">\n<meta 
name="DC.Rights" content="Copyright (C) Peter Rosenberg, Beinwil bei Muri 
(Aargau), Switzerland">\n<style type="text/css">\nbody {font:normal 10pt Arial; 
border:0px; margin:0px}\ntable {border:0px; table-layout:auto; border-
collapse:collapse; empty-cells:show; font:normal 10pt Arial; cursor:default;}
\ntd {border:1px solid #CCCCCC; padding-left:2px; padding-right:2px; padding-
top:1px; padding-bottom:1px;}\n</style>\n</head>\n<body style="margin-
right:30px"><TABLE style="width:400px"><tr>\n<td style="width:200px; white-
space:nowrap; text-align:left;">Benutzername</td>\n<td style="width:170px; 
white-space:nowrap; text-
align:left;">Passwort</td>\n</tr>\n</table>\n</body>\n</html>\n';htmString_Foote
r='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 
4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html>\n<head>\n<meta http-
equiv="content-type" content="text/html; charset=ISO-8859-1">\n<meta 
name="DC.Rights" content="Copyright (C) Peter Rosenberg, Beinwil bei Muri 
(Aargau), Switzerland">\n<style type="text/css">\nbody {font:normal 10pt Arial; 
border:0px; margin:0px}\ntable {border:0px; table-layout:auto; border-
collapse:collapse; empty-cells:show; font:normal 10pt Arial; cursor:default;}
\ntd {border:1px solid #CCCCCC; padding-left:2px; padding-right:2px; padding-
top:1px; padding-bottom:1px;}\n</style>\n</head>\n<body style="text-
align:right; margin:0px;"><form><input type="button" value="(S)chliessen" 
accesskey="s" onClick="javascript:parent.close();"></form></body>\n</html>\n';

	window_x=(screen.width/2)-350;window_y=(screen.height/2)-
250;window_width=700;window_height=500;



	function action
(mode,windowClose,windowNew,windowHref,windowName,windowParameters,idValue)
	{
 		if (mode=='1')
		{
			if (windowNew=='1')
			{
			}else{
// Problem
// alert('test');
window.open("xx","xx");
			}

				vMode = mode;
				vWindowClose = windowClose;
				vWindowNew = windowNew;
				vWindowHref = windowHref;
				vWindowName = windowName;
				vWindowParameters = windowParameters;
				vIdValue = idValue;
		}
		if (windowClose=='1')
		{
			window.close();
		}
	}

	function rowMark(mode,id)
	{
		switch(mode)
		{
			case 1:
				parent.main.document.getElementById
(id).style.backgroundColor = htmString_rowBackgroundColorFocus;
				parent.left.document.getElementById
(id).style.backgroundColor = htmString_rowBackgroundColorFocus;
				break;
			case 0:
				parent.main.document.getElementById
(id).style.backgroundColor = htmString_rowBackgroundColorNormal;
				parent.left.document.getElementById
(id).style.backgroundColor = htmString_rowBackgroundColorNormal;
				break;
		}
	}  

  function window_init(){
    window.resizeTo(window_width,window_height);
    window.moveTo(window_x,window_y);
  }

  function window_setFocus(){
    window.focus();
  }

  function frameHeader_init(){
    return htmString_Header;
  }

  function frameMain_init(){
    return htmString_Main;
  }

  function frameControl_init(){
    return htmString_Control;
  }

  function frameFooter_init(){
    return htmString_Footer;
  }

  function frameLeft_init(){
    return htmString_Left;
  }

  function frameTopLeft_init(){
    return htmString_TopLeft;
  }

  function xframeTopLeft_init(){
    return htmString_TopLeft;
  }

  function frameBottomLeft_init(){
    return htmString_BottomLeft;
  }

  function synchronizeIE(){
    this.header.scroll(this.main.document.body.scrollLeft,0);
    this.left.scroll(0,this.main.document.body.scrollTop);
    this.footer.scroll(this.main.document.body.scrollLeft,0);
  }

  function synchronizeNS(){
    this.header.scroll(window.main.pageXOffset,0);
    this.left.scroll(0,window.main.pageYOffset);
    this.footer.scroll(window.main.pageXOffset,0);
  }


  window_init();
  window_setFocus();

  function sync_init(){
    bType = (document.all) ? 1 : 0;
    if (bType){
      window.setInterval("synchronizeIE()",5);
    } else {
      window.setInterval("synchronizeNS()",5);
    }
  }

//-->

</script></head>
<frameset rows="25,*,24,0"><frameset cols="30,*"><frame 
src="javascript:parent.frameTopLeft_init();" name="topLeft" noresize="noresize" 
scrolling="no" border="0" frameborder="0" framespacing="0"><frame 
src="javascript:parent.frameHeader_init();" name="header" noresize="noresize" 
scrolling="no" border="0" frameborder="0" framespacing="0"></frameset><frameset 
cols="30,*"><frame src="javascript:parent.frameLeft_init();" name="left" 
noresize="noresize" scrolling="no" border="0" frameborder="0" 
framespacing="0"><frame src="javascript:parent.frameMain_init();" name="main" 
noresize="noresize" scrolling="yes" border="0" frameborder="0" 
framespacing="0"></frameset><frameset cols="30,*"><frame 
src="javascript:parent.frameBottomLeft_init();" name="bottomLeft" 
noresize="noresize" scrolling="no" border="0" frameborder="0" 
framespacing="0"><frame src="javascript:parent.frameFooter_init();" 
name="footer" noresize="noresize" scrolling="no" border="0" frameborder="0" 
framespacing="0" onload="javascript:sync_init();"></frameset><frame 
src="javascript:parent.frameControl_init();" name="control" noresize="noresize" 
scrolling="no" border="0" frameborder="0" framespacing="0"></frameset>
<noframes>
<body>
<p>
frames are not supported
</p>
</body>
</noframes></html>
(Reporter)

Comment 1

15 years ago
Created attachment 100645 [details]
The html-document that shows the problem with the javascript command window.open()

Comment 2

15 years ago
Confirming bug with Mozilla trunk binary 20020924xx on WinNT.
Load the HTML testcase, click on the rows, and you get the 
reported errors in the JavaScript Console

These are DOM errors; reassigning to DOM Level 0 -

Assignee: rogerl → jst
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM Level 0
Ever confirmed: true
QA Contact: pschwartau → desale
(Reporter)

Comment 3

15 years ago
I found a solution for the problem. The window.open() command doesn't work if I
use the command without the prefix http:// or file:// in the first parameter.
The error message don't tell me that if this prefix is missing... only some
cryptical values ;-). But anyway - now it works. I'm not sure wheter this is
only a workarround or the real solution. Maybe it's recommended to make further
investigations. But for me this bug is solved.

By the way: The NS V 7.0 is very good!!! For me it's very important that my
web-applications support the NS.

Comment 4

15 years ago
Created attachment 104670 [details]
Example of failure of Window.Open (dhtmltest.html)

This is the main page.	This page calls additem.html

Comment 5

15 years ago
On both NS 7.0 and Mozilla 1.2b ( Mozilla/5.0 (Windows; U; Windows NT 5.0;
en-US; rv:1.2b) Gecko/20021016 ), I am getting a similar problem with window.open.

I have a URL example:  http://www.edmeades.ca/test/dhtmltest.html

I found the issue when I was attempting to allow a user to populate a table from
another page "popped" by a window.open.  If the user adds a product from the
"floating" window to the table in the calling page, and the user then clicks on
the camera icon on the newly added row to display the image, the window.open
fails.  In my example, if the user adds a product from the table on the same
page to the "current order" table, and then clicks on the camera icon on the
newly added row, the window.open succeeds.

I have found that if I supply the full http:// URL in the window.open, then it
works.

This functionality does work with IE 6.0 SP1

Comment 6

15 years ago
Created attachment 104671 [details]
Pop -up window associated with dhtmltest.html (additmes.html)

This page is called by dhtmltest.html via window.open.	Using this is causing
the window.open on the main page to not work once a row has been added to a
table on the main page.

Updated

15 years ago
Attachment #104670 - Attachment description: Example of failure of Window.Open → Example of failure of Window.Open (dhtmltest.html)
Attachment #104670 - Attachment mime type: text/html → text/plain

Updated

15 years ago
Attachment #104671 - Attachment description: Pop -up window associated with dhtmltest.html → Pop -up window associated with dhtmltest.html (additmes.html)
Attachment #104671 - Attachment mime type: text/html → text/plain

Comment 7

15 years ago
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030113

I have a similar result when I try to open a URL with an invalid scheme (i.e.
"dispatch://" instead of "http://"). In this situation, the error code is
0x804b0012. I don't consider this an error, but perhaps a nicer explanation
would be possible.

I can provide more information if needed.
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs

Comment 9

14 years ago
I'm seeing this same problem on Windows 2000 and XP Pro with version 0.8. I have
the tabbrowser extention installed on both machines.
Assignee: general → nobody
QA Contact: desale → general
You need to log in before you can comment on or make changes to this bug.