SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Script for alert box

    Looking for a javascript that when a link is clicked a windows alert box pops up with a message and a button, then when the visitor clicks the button they go to another web page.
    I've seen javascripts for the alert box, but they don't include the move to another web page.

    Any ideas?

    Thanks

  2. #2
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should do the trick:

    <a href="otherpage.html" onClick="alert('Redirecting you to another page - click OK'); return true;">Click Here</a>

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this i havent tested it, but let me know if u have probs with it.

    PHP Code:
    <script type="text/javascript">

    var 
    msgA = new Array
    msgA[0] = 'no defined msg';
    msgA[1] = 'default msg box 2';
    msgA[2] = 'default msg box 3';
    msgA[3] = 'default msg box 4';
    msgA[4] = 'default msg box 5';

    function 
    notify(msgpredefined)
    {
     if (
    msg==null || msg==''alert(msgA[0]);
     else if (
    predefined != null || predefined==''alert(msgA[predefined])
     else 
    alert(msg)
    }
    //calls can be
    notify('your msg',3);

    </script> 

  4. #4
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Andrew, can I just ask what is the need to be so complex about the solution?

    In this case, what it is about your script that makes it a good alternative to Skunk's simple, standard and much smaller script?

    I understand what your script does (mostly ) and I also recognise that the first solution answers IdeaGuy's needs perfectly.
    I don't understand why such a complex (alternative) solution would be good for such a simple requirement.

    What am I missing?
    I am genuinely interested to know
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well I intended on just showing a simple function for it, but i got a bit bored and elaborated on it a little bit lol.

    It really is a simple script though, with a added feature of having default msg's, it would probably have been better using a case tho:P
    PHP Code:
    <script type="text/javascript">

    var 
    msgA = new Array
    msgA[0] = 'no defined msg';
    msgA[1] = 'default msg box 1';
    msgA[2] = 'default msg box 2';
    msgA[3] = 'default msg box 3';
    msgA[4] = 'default msg box 4';
    msgA[5] = 'default msg box 5';

    function 
    notify(msgpredefined)
    {
     if (
    msg==nullalert(msgA[0]);
     else if (
    predefined != null || predefined==''alert(msgA[predefined])
     else 
    alert(msg)
    }
    //calls can be
    notify('',1);

    </script> 


Bookmarks

Posting Permissions

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