zoukankan      html  css  js  c++  java
  • 使用form的target属性屏蔽url跳

    target:

    指定公开赛, action URL。

    关键点:

    让target指向隐藏的iframe


    demo:

    form.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript">
    	function doSave(){
    		var param = "?

    method=add"; testForm.action='handler.jsp' + param ; testForm.submit(); } </script> </head> <body> <form id="testForm" name="testForm" method="post" target="sub_frame"> id:<input type="text" name="id"><input type="button" value="提交" onclick="doSave();"> <iframe id="sub_frame" name="sub_frame" height="0" width="0" frameborder="0" marginheight="0" marginwidth="0" ></iframe> </form> <br/>id值: <input id="content" name="content" type="text"> </body> </html>


    handler.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <%
    String method=request.getParameter("method");
    if("add".equals(method)){
    	String id =request.getParameter("id");
    	out.println("<script type='text/javascript'>");
    	out.println("parent.document.getElementById('content').value='"+id+"';");
    	out.println("</script>");
    }
    %>



  • 相关阅读:
    BZOJ 3625: [Codeforces Round #250]小朋友和二叉树
    HDU 2069 Coin Change
    HDU 1709 The Balance
    HDU 1398 Square Coins
    HDU 1171 Big Event in HDU
    HDU 1085 Holding Bin-Laden Captive!
    BZOJ 3167: [Heoi2013]Sao
    BZOJ 1408: [Noi2002]Robot
    BZOJ 3163: [Heoi2013]Eden的新背包问题
    【Tsinsen-A1486】树(王康宁) 点分治 + Trie
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5047869.html
Copyright © 2011-2022 走看看