How to use onload event in dynamically inserted html file.
如何在动态插入的html文件中使用onload事件。
For example
<li><a href="sample.html></li>
this line im using in tab panel. When I click on this tab panel header, the sample.html
file will inserted in tab panel, in that time I need to trigger the onload
event in sampel.html
file
这一行我在选项卡面板中使用。当我单击此选项卡面板标题时,sample.html文件将插入选项卡面板,那时我需要在sampel.html文件中触发onload事件
<div id="tabs">
<ul>
<li>
<a href="sample.html">load html file</a>
</li>
</ul>
</div>
1 个解决方案
#1
2
I feel something needs to be clarified:
我觉得有些事情需要澄清:
-
onload
events are only fired when the "main" HTML page (i.e.window.document
) finishes loading for the first time. -
onload
events are not fired when you change a part of your page using Ajax and JavaScript (which is what actually happen when you're using tabs) .
onload事件仅在“主”HTML页面(即window.document)第一次完成加载时触发。
使用Ajax和JavaScript更改页面的一部分时,不会触发onload事件(这是使用选项卡时实际发生的情况)。
You should really consult the documentation of whichever tabs framework you used, it probably provides other events to detect when a tab changed.
您应该查阅您使用的任何选项卡框架的文档,它可能提供其他事件来检测选项卡何时更改。
For instance, jQuery has a tabs load
event:
例如,jQuery有一个标签加载事件:
$( ".selector" ).tabs({
load: function( event, ui ) {}
});
// or
$( ".selector" ).on( "tabsload", function( event, ui ) {} );
#1
2
I feel something needs to be clarified:
我觉得有些事情需要澄清:
-
onload
events are only fired when the "main" HTML page (i.e.window.document
) finishes loading for the first time. -
onload
events are not fired when you change a part of your page using Ajax and JavaScript (which is what actually happen when you're using tabs) .
onload事件仅在“主”HTML页面(即window.document)第一次完成加载时触发。
使用Ajax和JavaScript更改页面的一部分时,不会触发onload事件(这是使用选项卡时实际发生的情况)。
You should really consult the documentation of whichever tabs framework you used, it probably provides other events to detect when a tab changed.
您应该查阅您使用的任何选项卡框架的文档,它可能提供其他事件来检测选项卡何时更改。
For instance, jQuery has a tabs load
event:
例如,jQuery有一个标签加载事件:
$( ".selector" ).tabs({
load: function( event, ui ) {}
});
// or
$( ".selector" ).on( "tabsload", function( event, ui ) {} );