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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shoutbox controls

Status
Not open for further replies.

internetguy

Technical User
Nov 22, 2003
57
0
0
US
ok, I have a javascript function that opens a shoubox when you click a link. I have a pair of on/off links, and I know how to do the on, but I do not know how to close the window from the main page. I also want this shoutbox window to display on top of the main page. Here is my opener script

function shoutOut(url)
{
window.open(url,'shoutbox',config='height=600,width=500,toolbar=no,scrollbars=no,menubar=no,status=no,resizable=no');
}

<a href="javascript:void(0);" onClick="shoutOut('shoutbox.php');">On</a>

If you can help me with the two problems I have it would be greatly appreciated.
 

I haven't tested this, but something like this should work:

Code:
var shoutWinHandle = null;
function shoutOut(url) {
	shoutWinHandle = window.open(url, 'shoutbox', 'height=600,width=500');
}

function shoutShut() {
	if (shoutWinHandle != null) shoutWinHandle.close();
	shoutWinHandle = null;
}

<a href="javascript:void(0);" onclick="shoutOut('shoutbox.php');">On</a>
<a href="javascript:void(0);" onclick="shoutShut();">Off</a>

Hope this helps,
Dan
 
yup, that should work...

Known is handfull, Unknown is worldfull
 
Sorry guys it didn't work. I am curious what is the shoutWinHandle's purpose? Shouldn't it be directed to the shoutbox?
 
It works fine for MSIE6.0
Code:
[b]<script>[/b]
var shoutWinHandle = null;
function shoutOut(url) {
    shoutWinHandle = window.open(url, 'shoutbox', 'height=600,width=500');
}

function shoutShut() {
    if (shoutWinHandle != null) shoutWinHandle.close();
    shoutWinHandle = null;
}
[b]</script>[/b]

<a href="javascript:void(0);" onclick="shoutOut('shoutbox.php');">On</a>
<a href="javascript:void(0);" onclick="shoutShut();">Off</a>
'shoutWinHandle' is a variable that represents 'shoutbox' window, so we can easily modify the window via 'shoutWinHandle', e.g.
Code:
shoutWinHandle.close();
 
Alright it works great now, thanks a lot! Any clues on how to keep the window displayed on top of the main window? I have seen several ways online but none work....
 
try a showModalDialog box...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top