Help - Search - Members - Calendar
Full Version: Trying to debug a little problem that has to do with making a new window.
HTMLHelp Forums > Programming > Client-side Scripting
Elizara
Once upon a time, a friend of mine along with me got a very nice Javascript to open windows with a click of a mouse. He may of gotten it somewhere, I don't know.

I use it a lot on this site: http://maryadavies.250free.com/rpgamerboard (I'll list out the code in a second)

The only problem is; for links to outside sites in said window, I've always used target=blank in the links. With tabbed browsers, THAT opens a new tab. (Which in a little window, does not look very nice.) I'd either like that to 1. Open said sites in first window in new tab or 2. Open in whole new window.

Is there something I can change in the HTML or a Javascript I can add to the files to force a new window or put it in first window? Thank you.


As for the java script:

(In head of document)

<script type="text/javascript">
function popup(url,popup_w,popup_h)
{
// (url,height,width)
var popup = "height=" + popup_h + ",width=" + popup_w + ",scrollbars=yes";
window.open(url,"",popup);
}
</script>

At link:

<a href="java script:popup('fileforpopup.html',width, height)">
pandy
QUOTE
Is there something I can change in the HTML or a Javascript I can add to the files to force a new window or put it in first window?

You can't control if the page opens in a new window or a new tab, as that is a browser setting.

You can, with JavaScript, ensure the page opens in the window that opened the popup. You refer to that window with 'opener'.

CODE
opener.location.href = '[URL]';
Darin McGrew
CODE
<a href="fileforpopup.html">
would avoid the problem by letting the user decide whether to open the link in the same window, in a new window, or in a new tab.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.