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

Q1194 How to make the pop-up window only come up for every nth visitor, say every 10th visitor, instead of for every visitor to a web-site?

You are here: irt.org | FAQ | JavaScript | Random | Q1194 [ previous next ]

What you can do is amend the script such that it only opens a popup window approx. every one in nth times, by adding a random number:

<script language="JavaScript"><!--
var nth = 10;
var rnd = Math.floor(Math.random() * nth) + 1;

if (rnd == nth) {
     var windowHandle = window.open('popup.htm','windowName','width=400,height=400');
}
//--></script>

©2018 Martin Webb