a域a1页面:http://a/a1.htm
b域b1页面:http://b/b1.htm
a1页面中放一个iframe(id为if1),src指向b1页面
因为跨域:即a!=b
那么在a1页面不能:
var s = frames.if1.location.href;(没有权限)
却可以:
frames.if1.location.href = "....";那么在b1页面不能:
var s = parent.location.href;(没有权限)
却可以:
parent.location.href = "....";对于location.hash这两者都是没有权限。为什么?还有那些属性是这样的?location.href的这种情况类似只写权限;可能是javascript引擎故意预留的。
这是虫洞的基础。
然后用#代替?到达保持状态目的。
从而达到跨域传值。
当然这种跨域传值是基于a和b的配合实现的,所以没有安全问题。关于虫洞,可用“跨域 iframe 虫洞”搜寻。