如何在页面加载时加载 Javascript

How to make Javascript load on pageload

我想让这个 JS 函数从一个按钮变成一个页面加载

我正在将 jira 问题收集器集成到我们的网页中。

<a href="#" id="myCustomTrigger">Bug Report</a>

<script type="text/javascript" src=""></script>
<script type="text/javascript">window.ATL_JQ_PAGE_PROPS =  {
"triggerFunction": function(showCollectorDialog) {
//Requires that jQuery is available! 
jQuery("#myCustomTrigger").click(function(e) {
e.preventDefault();
showCollectorDialog();
});
}};</script>

要在页面重新加载时加载,我使用了 window.onload 但它不起作用

添加文档完成jquery处理程序:

$(document).ready(function(){    
      showCollectorDialog();
});

一旦文档完全加载,这将 运行。

在这里你可以用 jquery 来做,就像 this.You 可以把它放在你的 html 的末尾 file.And 也包括 jquery html 文件中脚本标签中的 cdn。

$(document).ready ( function(){
  alert('hello world');
});​

或者你可以这样做

function functionName() {
    alert('hello world');
}

window.onload = functionName;

寻找一个简单的答案,现有的谷歌搜索没有任何效果。

不需要自定义触发器。 把这个放到你的 html 头上,它会触发表格,我刚刚测试过 ;-)

<script type="text/javascript">
setTimeout(function() {

$('#atlwdg-trigger').trigger('click');

},100);
</script>