Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?

irt.org | Knowledge Base | JavaScript | Random | Q1194 [ previous next ]

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?

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.