Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript alert

    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

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    How about no alert at all?

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,303
    Thanks
    203
    Thanked 2,562 Times in 2,540 Posts
    <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>

  • #4
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dont you think i thought of that?

    Quote Originally Posted by Brandoe85
    How about no alert at all?
    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!!

  • #5
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Quote Originally Posted by solarwind2424
    the point is i want an alert or why else would i post this forum? ...smart people
    You tell me...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •