Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 12
Trades: 0
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
View Public Profile Visit Gibson's homepage!
 
 
Register now for full access!
Old 08-25-2006, 07:06 AM Re: Closing Parent Window script help
saadatshah's Avatar
Extreme Talker

Posts: 215
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Trades: 0
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>
__________________
- -- --- ---- ----- ------ ------- ---------------
If you have knowledge, let others light their candles in it.
saadatshah is offline
View Public Profile Visit saadatshah's homepage!
 
Old 08-25-2006, 06:19 PM Re: Closing Parent Window script help
kIDJOE's Avatar
Extreme Talker

Posts: 186
Location: Hollywood, CA
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

kIDJOE is offline
View Public Profile Visit kIDJOE's homepage!
 
Closed Thread     « Reply to Closing Parent Window script help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.11710 seconds with 12 queries