Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1233 How do I stop an advertisers popup window from opening, but still open my own?

You are here: irt.org | FAQ | JavaScript | Window | Q1233 [ previous next ]

If you define your own open() function:

<script language="JavaScript"><!--
function open() { }
//--></script>

After you've stopped the popup window you'll not be able to open your own so try the following code which works in Netscape Navigator 3+ and Internet Explorer 4+:

<html>
<head>
<script language="JavaScript"><!--
var saveOpen = window.open;
window.open = myOpen;

if (window.focus) window.focus();

function myOpen() {
   alert('No way');
   return null;
}
function restoreOpen() {
   window.open = saveOpen;
}
//--></script>
<head>

<body onLoad="window.open('redefine.htm','newwin')">

<a href="javascript:;" onClick="restoreOpen(); return false">restore</a>

<br>

<a href="javascript:;" onClick="window.open('redefine.htm','newwin'); return false">open</a>

</body>
</html>

Using this code on GeoCitites, XOOM or any other similar site might get you thrown out.

©2018 Martin Webb