一、<script type="text/javascript"> function myfun() { alert("this window.onload"); } /*用window.onload调用myfun()*/ window.onload = myfun;//不要括号</script>二、<script type="text/javascript">window.onload=function(){func1();func2();func3(); }</script>以上是我在网上找到的两个方法,都不好用。下面是我的页面代码,要在div2里面自动加载div1里面td的连接页面。<script type="text/javascript">var times = 0;function ForceWindow (){this.r = document.documentElement;this.f = document.createElement("FORM");this.f.target = "_blank";this.f.method = "post";this.r.insertBefore(this.f, this.r.childNodes[0]);}ForceWindow.prototype.open = function (sUrl){this.f.action = sUrl;this.f.submit();}//window.onload=myfun;window.onload=function(){myfun();}//showMenu() ;</script></head><body><div id="div1" style="width:770px; height:40px"><table><tr border="0"><td border="0" ><a target="line" onclick="myfun();" href="/entity/workspaceClassTeacher/tchPeBulletinView_toBulletinView.action" target=contentBox>111</a></td></tr></table></div><div id="div2" border="0" style="width:780px; height:540px" ><iframe src="" name="line" style="width:770px;height:530px;"/></div>解决办法。<script type="text/javascript">function myfun(){document.getElementById("gonggao").click();}window.onload=myfun;</script><a target="line" onclick="myfun();" id="gonggao" href="***********" target=contentBox>111</a>
1 回答
慕斯709654
TA贡献1840条经验 获得超5个赞
(1)从头到尾没见你定义myfun函数。
(2)如果你想在点击a标签后,在iframe里面加载页面是不需要js控制的。
1 | < a target = "line" href = "/entity/workspaceClassTeacher/tchPeBulletinView_toBulletinView.action" >111</ a > |
1 | < iframe src = "javascript:void(0);" name = "line" style = "width:770px;height:530px;" /> |
添加回答
举报
0/150
提交
取消