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 12 of 12
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    The Forums
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question question ~ please read

    how do i make a confirm box that makes the user go back 1 page into history? therfor, going to the previous page. please help
    ?


    digicam

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,694
    Thanks
    0
    Thanked 232 Times in 227 Posts
    Hi there digicam,

    Here is a Silly example, I have made two pages so that
    you may see how it works.

    Page one...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta content="mshtml 6.00.2800.1264" name="generator" />
    <title>page one</title>
    </head>
    <body>
    <div>
    You are here so 
    <a style ="text-decoration:none;color:#ff0000;"href="page_two.html">
    go there
    </a>
    </div>
    </body>
    </html>
    Page two...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta content="mshtml 6.00.2800.1264" name="generator" />
    <title>page two</title>
    <script type="text/javascript">
    <!--
    function question()
    {
    if(confirm("If you are  homesick.... click OK"))
    {
    history.go(-1);
    }
    else
    {
    alert("Not homesick, stay here then")
    }
    }
    //-->
    </script>
    </head>
    <body>
    <div>
    You have here arrived safely so 
    <a style ="text-decoration:none;color:#ff0000;"href="#"onclick="question();">
    click this
    </a>
    </div>
    </body>
    </html>
    Page one will take you to page two.
    the confirm box will take you back....or not

    cthead

  • #3
    New Coder
    Join Date
    Jan 2004
    Location
    The Forums
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    alright. thanks. ill have to test it out.



    (tested)

    thanks for the code. its valid. i appreciate it.
    Last edited by digicam; 01-04-2004 at 07:32 PM.
    ?


    digicam

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Next time read the posting guidelines, especially make note of number 2

  • #5
    New Coder
    Join Date
    Jan 2004
    Location
    The Forums
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry... i was going to do that but the wuestion was too long to put in the field box...
    ?


    digicam

  • #6
    New Coder
    Join Date
    Jan 2004
    Location
    The Forums
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    also, i spiced up the code a bit. make sure you name the files: "page_1" and "page_two"

    Page one ~
    Code:
    <center>
    <b>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta content="mshtml 6.00.2800.1264" name="generator" />
    <title>page one</title>
    </head>
    <body>
    <div>
    You are at home. If you want to go to school, go
    <a style ="text-decoration:none;color:#000000;"href="page_two.html">
    here
    </a>
    </div>
    </body>
    </html>
    </b>
    </center>
    Page two ~
    Code:
    <center>
    <b>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta content="mshtml 6.00.2800.1264" name="generator" />
    <title>page two</title>
    <script type="text/javascript">
    <!--
    function question()
    {
    if(confirm("If you are homesick click OK. If not click Cancel"))
    {
    history.go(-1);
    }
    else
    {
    alert("Not homesick? Stay here then")
    }
    }
    //-->
    </script>
    </head>
    <body>
    <div>
    Your at school. Are you homesick? If so, go
    <a style ="text-decoration:none;color:#000000;"href="#"onclick="question();">
    here
    </a>
    </div>
    </body>
    </html>
    ?


    digicam

  • #7
    Regular Coder
    Join Date
    Dec 2003
    Location
    USA
    Posts
    230
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by digicam
    also, i spiced up the code a bit
    Where...?

  • #8
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    He made the code invalid by adding <center><b>Outside the <html> tags

  • #9
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Cthead;

    Welcome to Coding Forums.

    .....Willy

    Edit: You too digicam.
    Last edited by Willy Duitt; 01-05-2004 at 06:06 AM.

  • #10
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,694
    Thanks
    0
    Thanked 232 Times in 227 Posts
    Hi there Willy,

    Thanks for the welcome.
    It's nice to be here with you
    Arrived here via your link at the 'City'

    cthead

  • #11
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    This is a javascript question! Please post in the correct forum, and like NightFire said take note of the posting guidelines ..
    Omnis mico antequam dominus Spookster!

  • #12
    New Coder
    Join Date
    Jan 2004
    Location
    The Forums
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i changed some of the words around.
    Last edited by digicam; 02-28-2004 at 05:35 PM.
    ?


    digicam


  •  

    Posting Permissions

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