亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如果想要實現自動加載onclick方法?這個該怎么操作?

如果想要實現自動加載onclick方法?這個該怎么操作?

慕絲7291255 2021-08-13 15:11:42
一、<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;"/>


查看完整回答
反對 回復 2021-08-16
  • 1 回答
  • 0 關注
  • 317 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號