一、<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
提交
取消