日期:2014-05-16  浏览次数:20446 次

如何访问IFRAME里的元素
如果让test函数可以正常执行呢
刚才测试过如果iframe的src和本网页是一个域内则可以正常执行.但问题是我IFRAME是外网站的,请问有没什么设置可以对IFRAME里是外网站的情况进行控件赋值呢?
<!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=gb2312 "   />
<title> 无标题文档 </title>
<script   language= "javascript ">
function   test()
{
//alert(main.document.getElementById( 'from ').value);
main.document.getElementById( 'from ').value= '东街口啊 ';
return;
//alert(document.frames[ "main "].document.all[ "username "].value)
//document.frames[ "main "].document.all[ "username "].value   =   "username ";
//document.frames[ "main "].document.all[ "password "].value   =   "fc ";
}
</script>
</head>

<body>

<input   type= "button "   name= "Submit "   value= "按钮 "   onclick= "test(); "   />
<iframe   src= "http://so.fzs8.com/bus.asp "   width= "100% "   height= "100% "   id= "main "   name= "main "> </iframe>
</body>
</html>


------解决方案--------------------


外部网页中不一定含有 “form”啊
------解决方案--------------------
跨域的就不要想啦
------解决方案--------------------
同意楼上的如果跨域都可以随便访问的话那安全性太差了.想想看把一个网上银行的也面嵌到你的iframe然后修改表单的action使提交到自己的网站,那不是很可怕吗.
------解决方案--------------------
注意一定加parent
比如parent.ifram1
------解决方案--------------------
跨域是不能访问的!!还有.你的访问一个域成功的JS代码是上面的吗?有没有试过访问iframe中的服务器控件呢?