...

View Full Version : javascript alert



solarwind2424
03-18-2005, 02:34 AM
lets say i have a website and i want to alert the user when the body loads
-----------------------------------------------------------
blah blah blah...

function alerter()
{

alert("WELCOME TO VG's AND V2's WEBSITE!");

}
blah blah blah blah...
<body onload="alerter()">
--------------------------------------------

I know how to do that

but when the user refreshes or clicks a link back to index.html, the alert comes again. How do i make it so it only comes once. Probably with a variable in javascript alerting if the variable is 0 and it increments after

please help me

Brandoe85
03-18-2005, 04:33 AM
How about no alert at all? :rolleyes:

Philip M
03-18-2005, 08:26 AM
<script>

//Alert once script- By Website Abstraction
//Credit notice must stay intact for use
//Visit http://wsabstract.com for this script

//specify message to alert
var alertmessage="Welcome to Website Abstraction!"editing required beyond here/////

//Alert only once per browser session (0=no, 1=yes)
var once_per_session=1


function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function alertornot(){
if (get_cookie('alerted')==''){
loadalert()
document.cookie="alerted=yes"
}
}

function loadalert(){
alert(alertmessage)
}

if (once_per_session==0)
loadalert()
else
alertornot()

</script>

solarwind2424
03-18-2005, 11:52 PM
How about no alert at all? :rolleyes:

the point is i want an alert or why else would i post this forum? ...smart people


...and thanks for the help with the code philip m!!

Brandoe85
03-19-2005, 01:34 AM
the point is i want an alert or why else would i post this forum? ...smart people

You tell me... :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum