Reply
Closing Parent Window script help
Old 08-24-2006, 08:20 AM Closing Parent Window script help
Novice Talker

Posts: 12
Hi!

I need some help please

I have a script that closes the parent browser (see below) but it displays a message asking if the user wants to close the browser. The script is triggered when logout (text not a button) is pressed
Code:
 
onclick="javascript:window.parent.close()

please can you tell me what i need to put to make the message dissapear?

Many thanks

Joe
Gibson is offline
Reply With Quote
View Public Profile Visit Gibson's homepage!
 
When You Register, These Ads Go Away!
Old 08-25-2006, 08:06 AM Re: Closing Parent Window script help
saadatshah's Avatar
Extreme Talker

Posts: 216
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Here goes Solution:

parent.html

HTML Code:
<html>
<head>
<title>Parent</title>
</head>
<body> 
<input type=button value="open plain" onclick="window.open('child.html');"><BR> 
<input type=button value="open & close me" onclick="window.open('child.html?yup=1');"> 
</body>
</html>
child.html

HTML Code:
<html>
<head>
<title>Child</title>
<script> 
function closeParent(){ 
try{ 
var q = queryString("yup"); 
if( q=="1" ){ 
var op = window.opener; 
op.opener = self; 
op.close(); 
} 
} 
catch(er) 
{} 
} 

function PageQuery(q) { 
if(q.length > 1) this.q = q.substring(1, q.length); 
else this.q = null; 
this.keyValuePairs = new Array(); 
if(q) { 
for(var i=0; i < this.q.split("&").length; i++) { 
this.keyValuePairs[i] = this.q.split("&")[i]; 
} 
} 
this.getKeyValuePairs = function() { return this.keyValuePairs; } 
this.getValue = function(s) { 
for(var j=0; j < this.keyValuePairs.length; j++) { 
if(this.keyValuePairs[j].split("=")[0] == s) 
return this.keyValuePairs[j].split("=")[1]; 
} 
return false; 
} 
this.getParameters = function() { 
var a = new Array(this.getLength()); 
for(var j=0; j < this.keyValuePairs.length; j++) { 
a[j] = this.keyValuePairs[j].split("=")[0]; 
} 
return a; 
} 
this.getLength = function() { return this.keyValuePairs.length; } 
} 
function queryString(key){ 
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
} 
</script> 
</head>
<body onload="closeParent();" > 
HELLO 
</body>
</html>
__________________
Traffic School - Driver Ed - Defensive Driving - Texas Defensive Driving - Online Traffic School - Defensive Driving Course
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Old 08-25-2006, 07:19 PM Re: Closing Parent Window script help
kIDJOE's Avatar
Extreme Talker

Posts: 180
Location: Hollywood, CA
Nice! so basicly what you do is create a JS bsic window.close function on the parent window and then from the child window instead of close.parent.window you call the function in the paren window

="window( or document, not sure).top(or parent not sure).Function();"

the not sures is cause I dont wanna try it but instead give you the idea
kIDJOE is offline
Reply With Quote
View Public Profile Visit kIDJOE's homepage!
 
Reply     « Reply to Closing Parent Window script help
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.38923 seconds with 12 queries