利用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");