用JavaScript接收html文件的参数 |
|
这个灵感是来于微软的FRAME指向的:
大家可以到 http://disapart.oso.com.cn/temp/urlinfo.html 做测试 ////////////////例子: <html><script> var i=0; function ol() { i=location.href.indexOf("?"); if(i!=-1) { str=location.href.substr(i+1,location.href.length-i-1); alert(str); document.open(true); document.write(unescape(str)); document.close(); } else { i=location.href.length; } } function os() { str=location.href.substr(0,i)+"?"+document.all.tags("textarea").item(0).value; location.href=str; } </script><body onload="ol()"> 试试在下面输入HTML代码:<br>请注意:因为字符串没有编码,,所以加入的Script可能会有错误 <br><textarea cols=100 rows=20> </textarea><br> <button onclick="os()">看看结果</button> </body></html> |