[thelist] window.name & target="name" issues

Robert Carpenter evolt at thebigcrux.com
Fri Dec 5 16:30:05 CST 2003

Hi all-

I'm having some problems with the window.name property and 
target="name" attribute in Safari and NN7, hoping that someone wiser in 
the ways of the DOM & JS can either point me towards a better or more 
proper way to approach this or confirm that I'm dealing with bugs in 
Netscape 7 & Safari.

I'm trying to spawn a new window from a link, and then load links or 
forms from that new window into the original window, then close the 
spawned window (I understand some folks may have some usability issues 
with this approach, but the clients are being very, uhh, client-like).

Here's some code snippets as they stand now, but I've tried numerous 
other variations as well:

----window 1----
//in the <head>
	window.name = "one";
	function openwin() {
		//I've also tried specifying the actual page, instd of about:blank

//in the <body>
	<a href="jstest2.html" target="two" onclick="openwin();">New Window</a>

This seems to work just fine, but the problem comes up when I try to 
load pages into the original page from links or forms in the spawned 
window, and then close the spawned window, like this:

----window 2----
//In the <head> : Close this window after the link/form loads -  
setTimeout() is for Netscape 7

	function closewin() {

//this link/form should load in the original window
	<a href="jstest3.html" target="one" onclick="closewin();return 
true;">Go Back</a>
	<form id="form1" action="jstest3.html" method="get" target="one" 
onsubmit="closewin();return true;">
		<input type="text" value="test" name="test2">
		<input type="submit">

All of this seems to work just fine in IE (mac/win), netscape 4.x, but 
fails in NN7 & Safari, albeit differently:

NN7.x: Only works if I include the setTimeout(x,y) as above, and form 
submission fails with the browsers default behavior of showing a 
"non-secure form" warning if not using SSL.

Safari: Just won't load the link into the original window, even though 
it seems to know that it exists (for example, window.opener.name yields 
the proper window name). More frustratingly, Safari *will* open links 
in a name-targeted window, but only if the target window has been 
spawned previously by that window, i.e., it works if I A)spawn a new 
window ("one"), B)click a link in "one" with target="three" (this opens 
new window), and  C)further links in "one" with target="three" will 
work as expected.

Hope all of this makes sense and that I'm giving enough info to work 


More information about the thelist mailing list