简体   繁体   中英

How do I get javascript to get a button to open another html page?

     First I must apologize Halnex for calling you Helix this whole time. I attempted to try your code but I am not getting my submit page to show up and I’m not completely sure why. Note I just copied the source code of JQuery to a file inside of one of my folders inside the folder holding these html pages.

<!DOCTYPE HTML>
<html>
    <HEAD>
        <title>WELCOME TO MY FORM PAGE</title>
<link rel="stylesheet type="text/css" href="style/style.css"> 
            <script src="jquery-1.12.4.min.js"></script>
            <script type="text/javascript">
                $(document).ready(function (){

                $('#button1').click(function (){

                    $('#response').load('form_submit.html');    
                    });
                });
            </script>
    </HEAD>
<BODY>

just two text boxes nothing special.

Registrations

Username:
password:
I'm not sure if these two lines are correct. Should maybe the input line be wrapping the div or something crazy like that?

 Maybe my issue is with my code on my file I'm trying to load (form_submit.html)? This is all I have on my form_submit.html file: Does this code below for the submission page look acceptable or could this be where I am failing? <!DOCTYPE HTML> <html> <head> <title>User Submission Page</title> </head> <body> Here are the details of the submitted form: </body> </html> 

As previously said, your button is trying to submit a form. To load an html page on button click use this.

<input type="button" id="button1" value="Load HTML Page">

<div id="response"></div>

The jQuery

$(document).ready(function() {
    $('#button1').click(function() {
        $('#response').load('test.html');
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM