Click to See Complete Forum and Search --> : Open New Window, either close or history.back parent


sleerk
07-15-2003, 08:20 PM
We have a VB application where we pop up an HTML file using VB code. However, if there is already a browser window open, this page opens up in the current window. Apparently there is no way of coding so that it always opens in a new window.

I could open a page which uses javascript to open the new window, then uses history.back to go back to the previous page. Ok, fine, but then if there WASNT a window already open, we end up with a blank window sitting there.

I could use window.close or similar to close the parent, but that's not wanted either - the previous page might be needed by the user.

Is there a way to get the script to do either of two options: If there is no history in the parent, close the window. If there is history in the parent, go back 1.

Of course, I dont want the warning message 'The web page you are viewing is trying to close the window'.

Thanks

Jeff

sleerk
07-15-2003, 10:32 PM
Looks like I've got it working, with a little bit of searching...

<script language="JavaScript">
function open_on_entrance(url,name)
{
new_window = window.open('tipofthemonth2.htm','about', ' menubar=no,resizable=no,status=no,width=800,height=580,left=0,top=0')
}

function jsGoBack()
{
if (window.history.length != 0)
{
window.history.back()
}

if (window.history.length == 0)
{
var pw=window.parent;pw.opener=window.self;pw.close()
}
}


</script>

</head>
<body onload="open_on_entrance();jsGoBack(); ">