...

View Full Version : how do u get so a random event happens



Antoniohawk
02-01-2004, 09:30 PM
Please elaborate, we don't have much of an idea of what you need.

egquen2000
02-02-2004, 03:27 AM
TRY THIS:


<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
closetime = 0; // Close window after __ number of seconds?
// 0 = do not close, anything else = number of seconds

function Start(URL, WIDTH, HEIGHT) {
windowprops = "left=50,top=50,width=" + WIDTH + ",height=" + HEIGHT;
preview = window.open(URL, "preview", windowprops);
if (closetime) setTimeout("preview.close();", closetime*1000);
}

function doPopup() {
url = "http://www.yoursite.com";
width = 100; // width of window in pixels
height = 100; // height of window in pixels
delay = 30; // time in seconds before popup opens
timer = setTimeout("Start(url, width, height)", delay*1000);
}
// End -->
</script>


</HEAD>

<BODY OnLoad="doPopup();">

trib4lmaniac
02-02-2004, 09:46 AM
If you mean make a something happen after a random number of seconds, you could write it inside a function and call it with a setTimeout()...


<script language="JavaScript">
<!--
function timeout_window()
{
var url="http://www.mysite.com";
var the_window="new_window";
var extras="height=200,width=200,location=no,toolbar=no";
window.open(url,the_window,extras);
}
function create_random(limit)
{
var the_num=Math.floor(Math.random()*limit);
return the_num;
}
var random_num=create_random(11);
setTimeout("timeout_window()",random_num*1000);
//-->
</script>


Hope this helps :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum