如何让javascript获得一个按钮来打开另一个html页面?

时间:2016-08-03 21:49:22

标签: javascript jquery html spring

     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>
只有两个文本框没什么特别的。         

注册记忆

                         用户名:
            密码:
             我不确定这两行是否正确。输入线应该包装div还是像那样疯狂的东西?                        

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>

1 个答案:

答案 0 :(得分:0)

如前所述,您的按钮正在尝试提交表单。要在按钮上加载html页面,请单击此处。

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

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

jQuery

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