<html>
<head>
<title>测试</title>
</head>
<body>
<iframe name=I1></IFRAME>
<script>
title=document.title;
//URL=document.URL;//不能用这个,只读的!
URL=encodeURI(location.href);//我这个函数名是不是写错了,需不需要编码,自己看着办。
document.I1.src="1.asp?title=" + title + "&URL=" + URL ;
</script>
</body>
</html>
<head>
<title>测试</title>
</head>
<body>
<iframe name=I1></IFRAME>
<script>
title=document.title;
//URL=document.URL;//不能用这个,只读的!
URL=encodeURI(location.href);//我这个函数名是不是写错了,需不需要编码,自己看着办。
document.I1.src="1.asp?title=" + title + "&URL=" + URL ;
</script>
</body>
</html>
还请多指教!
我说不编码是你得到的href 就是编过码的,就不用自己编。偶忘了是否本来就编过了的,你alert一下自己看是否编过了吧? 比如空格就变成了%2C。如果编过了就不用encodeURI了,没编过必须自己编码。
但是你最后的传递参数的那一句是不是有错呢?
怎么,1.asp文件中什么都显示不出来呢??(我的java比较差,还请赐教!)
偶用ID.
<iframe id=xx></iframe>
document.all.xx.src=...另外,iframe比较特殊。要访问作为页面元素的iframe,使用name或者id属性。
要访问作为子文档容器的iframe节点,使用document.frames(数字索引或者名字字符串)保险。例如:document.frames(0).document.body.innerHTML