感谢 看了他的资料我才明白怎么简单的使用window.name 下面是他的博客的地址
http://www.cnblogs.com/zjfree/archive/2011/02/24/1963591.html
下面是代码:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><script src="./jquery.min.js" type="text/javascript"></script><title>跨域获取数据</title><script type="text/javascript"> function domainData(url, fn) { var isFirst = true; var iframe = document.createElement('iframe'); iframe.style.display = 'none'; var loadfn = function() { if (isFirst) {//获取属性的中间的过滤文件的地址 作用是为了取消跨域报错
iframe.contentWindow.location = 'http://192.168.95.158:8080/ce/null.html'; isFirst = false; } else { fn(iframe.contentWindow.name); iframe.contentWindow.document.write(''); iframe.contentWindow.close(); document.body.removeChild(iframe); iframe.src = ''; iframe = null; } }; iframe.src = url; if (iframe.attachEvent) { iframe.attachEvent('onload', loadfn); } else { iframe.onload = loadfn; }document.body.appendChild(iframe);
}</script></head><body></body>
<script type="text/javascript"> domainData('http://192.168.95.158:8402/df/2.jsp', function(data) { alert(data); });</script></html>这是你要获取的window.name 的网站的事例
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><base href="<%=basePath%>"><title>My JSP '2.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"> --><script>window.name = '需要跨域传递的数据';</script></head><body>
This is my JSP page. <br></body></html>当然这也只是最简单的使用方式 有深入了解的可以给我提点下 不胜感激涕零