View Full Version : For you Java Experts
HotMop
01-30-2001, 11:04 AM
How can you have an exit console that randomly opens one of 3 different consoles. I only want to open one per exit.
For example, I have three different sponsor pages, I only want one of these pages to open for each surfer that leaves my site.
Is there a way to do this?
ThaKiller
01-30-2001, 11:27 AM
I would do it with a cgi but I'm quite sure there is a random() function in javascript which does the same http://bbs.adultwebmasterinfo.com/ubb/wink.gif
donger
01-30-2001, 01:00 PM
if you have php, just do this:
<html>
<head>
/* all your head crap here */
<?
$urls = array("http://url1.com/", "http://url2.com", "http://url3.com");
srand((double)microtime()*1000000);
?>
<body blah blah blah onUnload=window.open("<? echo $urls[rand(0,2)];?>");>
HotMop
01-30-2001, 03:32 PM
Ok...here's a stupid question. How do you know if you have php?
redbomb
01-30-2001, 03:43 PM
Telnet to your web server (port 80) and type:
HEAD / HTTP/1.0<and then hit enter twice)
you'll get something like this:
HTTP/1.1 200 OK
Date: Tue, 30 Jan 2001 17:12:52 GMT
Server: Apache/1.3.12 (Unix) PHP/4.0.2
X-Powered-By: PHP/4.0.2
Connection: close
Content-Type: text/html
HotMop
01-30-2001, 05:09 PM
I've tried this a few times and can't get it to work. Does anyone have any other ideas?
sonicpuke
01-31-2001, 05:18 AM
I get so few chances to show off my JavaScript nerdiness (Note it's not Java but JavaScript)
I think this code below should do what your saying. (If my formatting doesn't get too screwed up in posting I hope)
<script language=javascript>
exit=true;
function genRandom(num) {rsg=parseInt((Math.random()*num)+1);return rsg}
function MOUSE() {
if (exit) {
testwhich=parseInt((Math.random()*3)+1);
if (testwhich == 1) {
open("http://www.exitsite1.com/");
}
if (testwhich == 2) {
open("http://www.exitsite2.com/");
}
if (testwhich == 3) {
open("http://www.exitsite3.com/");
}
}
}
</script>
Also don't forget to put an onunload tag in the body tag to activate it like this http://bbs.adultwebmasterinfo.com/ubb/wink.gif
<body onunload="MOUSE()">
Easy money
Sonic
sonicpuke
01-31-2001, 05:19 AM
Whoops
function genRandom(num) {rsg=parseInt((Math.random()*num)+1);return rsg}
This line is not needed for the code to work.
Sonic
HotMop
01-31-2001, 10:58 AM
Works like a charm.
Shovel
01-31-2001, 04:59 PM
Just read this one in Andy's newsletter today...
<script LANGUAGE="JavaScript">
<!--
var z = 5;
Exit = new Array(z),
Exit[0] =("http://www.mysuperseller.com");
Exit[1] =("http://www.mysuperseller2.com");
Exit[2] =("http://www.mysuperseller3.com");
Exit[3] =("http://www.mysuperseller4.com");
Exit[4] =("http://www.andsoon.com");
file://-->
</script>
<script LANGUAGE="JavaScript">
<!--
function replace () {
var jetzt=new Date();
var z=(jetzt.getSeconds())%5;
window.open(Exit[z]);}
file://-->
</script>
----------------------------------------------------------------------------
-------------------------------------
you may have to edit some lines;
- ad as many Exits as you like ---> but you have to edit the line "var
z=(jetzt.getSeconds())%?;" and "var z=?;"( ? = Number of Exits ).
- Put the Script right after the <Body> Tag in your Html Code.
- you can call the Script with the onload - or onunload Handler in the
<Body> Tag ---->
<body onload="replace ()"> or <body onunload="replace ()">
vBulletin® v3.7.3, Copyright ©2000-2012, Jelsoft Enterprises Ltd.