pen_lord2000
09-14-2008, 01:12 AM
How would i make a pop up with one of three randomly generated messages. I dont want this pop up to show in a new window. :confused:
This is what I have so far.
<SCRIPT language="JavaScript">
function get_random()
{
var ranNum= Math.floor(Math.random()*3);
return ranNum;
}
function getaQuote()
{
var whichQuote=get_random();
var contents = '<html><head><title>Counter Window<\/title></head></html>';
var quote=new Array(3)
quote[0]="Switch to Firefox for a safer, more customizable web experience.";
quote[1]="Don't forget to sign the guestbook!";
quote[2]="Don't forget to vote in the weekly poll!";
alert(quote[whichQuote]);
}
getaQuote()
</SCRIPT>
I found this code on the internet but it doesnt have the randomly gen. msg.
<script language="JavaScript" type="text/javascript">
<!-- Copyright 2003, Sandeep Gangadharan -->
<!-- For more free scripts go to http://sivamdesign.com/scripts/ -->
<!--
var y1 = 140; // change the # on the left to adjuct the Y co-ordinate
(document.getElementById) ? dom = true : dom = false;
function hideIt() {
if (dom) {document.getElementById("layer1").style.visibility='hidden';}
}
function showIt() {
if (dom) {document.getElementById("layer1").style.visibility='visible';}
}
function placeIt() {
if (dom && !document.all) {document.getElementById("layer1").style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight-y1)) + "px";}
if (document.all) {document.all["layer1"].style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - (document.documentElement.clientHeight-y1)) + "px";}
window.setTimeout("placeIt()", 10); }
// -->
</script>
...then in the body part:
<div id="layer1" style="position:absolute; left:20; width:410px; height:10; visibility:hidden">
<font face="verdana, arial, helvetica, sans-serif" size="2">
<div style="float:left; background-color:yellow; padding:3px; border:1px solid black">
<span style="float:right; background-color:gray; color:white; font-weight:bold; width='20px'; text-align:center; cursor:pointer" onclick="javascript:hideIt()"> X </span>
Don't forget to sign the guestbook.</div>
</font>
</font>
</div>
This is what I have so far.
<SCRIPT language="JavaScript">
function get_random()
{
var ranNum= Math.floor(Math.random()*3);
return ranNum;
}
function getaQuote()
{
var whichQuote=get_random();
var contents = '<html><head><title>Counter Window<\/title></head></html>';
var quote=new Array(3)
quote[0]="Switch to Firefox for a safer, more customizable web experience.";
quote[1]="Don't forget to sign the guestbook!";
quote[2]="Don't forget to vote in the weekly poll!";
alert(quote[whichQuote]);
}
getaQuote()
</SCRIPT>
I found this code on the internet but it doesnt have the randomly gen. msg.
<script language="JavaScript" type="text/javascript">
<!-- Copyright 2003, Sandeep Gangadharan -->
<!-- For more free scripts go to http://sivamdesign.com/scripts/ -->
<!--
var y1 = 140; // change the # on the left to adjuct the Y co-ordinate
(document.getElementById) ? dom = true : dom = false;
function hideIt() {
if (dom) {document.getElementById("layer1").style.visibility='hidden';}
}
function showIt() {
if (dom) {document.getElementById("layer1").style.visibility='visible';}
}
function placeIt() {
if (dom && !document.all) {document.getElementById("layer1").style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight-y1)) + "px";}
if (document.all) {document.all["layer1"].style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - (document.documentElement.clientHeight-y1)) + "px";}
window.setTimeout("placeIt()", 10); }
// -->
</script>
...then in the body part:
<div id="layer1" style="position:absolute; left:20; width:410px; height:10; visibility:hidden">
<font face="verdana, arial, helvetica, sans-serif" size="2">
<div style="float:left; background-color:yellow; padding:3px; border:1px solid black">
<span style="float:right; background-color:gray; color:white; font-weight:bold; width='20px'; text-align:center; cursor:pointer" onclick="javascript:hideIt()"> X </span>
Don't forget to sign the guestbook.</div>
</font>
</font>
</div>