利用form的target屬性屏蔽url跳轉,formtargeturl跳轉

來源:互聯網
上載者:User

利用form的target屬性屏蔽url跳轉,formtargeturl跳轉

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>");}%>




HTML中 form 下的target 跳轉

你可以嘗試 用t1.js代替 t1.html,然後再t1.js裡邊的代碼用<script>document.write('這個獎t1.html的代碼都寫在這裡')</script>;

主要帶引號和雙引號 可能需要特出處理一下 就可以達到<div></div>包含 一段靜態html代碼了!
 
target屬性定向問題

做留言本我覺得可以不用像你那樣做,可以留言之後跳轉到留言查看頁,不用架構。
另:
window.open(url,"視窗名稱","width=610,height=437,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");後面的屬性分別是:工具列、地址欄、狀態列、功能表列、捲軸、是否可縮放。
標題列是不能沒有的,要實現你所說的可讓網頁全屏:window.open("要全屏的網頁","","fullscreen=yes");
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.