首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

open 窗口 跨域访问

2012-07-04 
open 窗口 跨域访问:open 窗口 跨域访问:问题:比如:www.A.com域名用 OPEN打开www.B.com里面的内容 选择www

open 窗口 跨域访问:
open 窗口 跨域访问:
问题:
比如:  www.A.com  域名  用 OPEN  打开  www.B.com里面的内容 选择www.B.com 里面的内容返回到 WWW.A.com

解决步骤:
1.在www.A.com  准备testAffix.jsp,iframe.jsp,data.jsp
2.在www.A.com  准备需要访问的.jsp

testAffix.jsp代码:

<%@ page language="java" contentType="text/html; charset=GBK"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>测试附件</title></head><body><input type="button" value="按钮" onclick="opens()"/><input type="text" value="" id="affixValue" name="affixValue"/><script type="text/javascript">function opens(){//var url="iframe.jsp?userName=人事科借阅";var url="iframe.jsp";window.open(url,'newwindow_db', 'height=600,width=760,toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=yes');//var obj=window.showModalDialog(url,window,'dialogWidth:900px;dialogHeight:600px;status:no');//alert('obj:'+obj.userId);}//affixValue 附件编号//remark  备注//isPrint 是否打印//userId  用户编号function setSelectAffixValue(affixValue,remark,isPrint,userId){alert('obj');alert(affixValue);document.getElementById("affixValue").value=affixValue;alert(remark);alert(isPrint);alert(userId);}</script></body></html>


iframe.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <body>  <iframe style="padding:0px;margin:0px;" src="http://192.168.0.197:8888/filemanage/module/interface/mainFrame.jsp?userName=人事科借阅&URL=http://192.168.0.197:8080/client/client/data.jsp"  width="100%" height="100%" frameborder="0" marginheight="0" marginwidth="0"  id="iframe" name="iframe"></iframe>  <script type="text/javascript">  function setSelectAffixValue(affixValue,remark,isPrint,userId){    opener.setSelectAffixValue(affixValue,remark,isPrint,userId);}  </script>  </body></html>


data.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
String affixId=request.getParameter("affixId");
String content=request.getParameter("content");
String printStr=request.getParameter("printStr");
String userId=request.getParameter("userId");
%>
<html>
  <head>
    <title>My JSP 'data.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">   
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
 
  <body>
  <script type="text/javascript">
  top.setSelectAffixValue('<%=affixId%>','<%=content%>','<%=printStr%>','<%=userId%>');
  </script>
  </body>
</html>


热点排行