利用location.hash传递参数
JS跨域操作Dom http://www.iteye.com/problems/56264
http://www.chinaz.com/web/2011/1123/222158.shtml
a.html:
- <!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>
- <title> new document </title>
- <SCRIPT LANGUAGE="JavaScript">
- <!--
- var src="";
- window.onload=function(){
- src=document.getElementById('ifrm_1').src;
- }
- function fn1(){
- var ifm=document.getElementById('ifrm_1'),ipt=document.getElementById('ipt');
- ifm.src=src+"#"+ipt.value;
- }
- //-->
- </SCRIPT>
- </head>
- <body>
- <input id="ipt" type="text" />
- <input type="button" value="test" onclick="fn1()"/><br/>
- <iframe id='ifrm_1' src='http://61b7.ipc.la/b.html'></iframe>
- </body>
- </html>
<!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> <title> new document </title> <SCRIPT LANGUAGE="JavaScript"> <!-- var src=""; window.onload=function(){ src=document.getElementById('ifrm_1').src; } function fn1(){ var ifm=document.getElementById('ifrm_1'),ipt=document.getElementById('ipt'); ifm.src=src+"#"+ipt.value; } //--> </SCRIPT> </head> <body> <input id="ipt" type="text" /> <input type="button" value="test" onclick="fn1()"/><br/> <iframe id='ifrm_1' src='http://61b7.ipc.la/b.html'></iframe> </body> </html>
b.html(http://61b7.ipc.la/b.html):
- <!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>
- <title> new document </title>
- <SCRIPT LANGUAGE="JavaScript">
- <!--
- window.onload=function(){
- var h=window.location.hash,s=document.getElementById('show'),ipt=document.getElementById('ipt');
- setInterval(function(){
- if(h!=window.location.hash){
- h=window.location.hash;
- ipt.value=h.replace('#','');
- }
- },100);
- }
- //-->
- </SCRIPT>
- </head>
- <body>
- <input id="ipt" type="text" />
- <div id="show"></div>
- </body>
- </html>