猿问

如何在页面加载时加载 Javascript

我想让这个 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 但这没有用


手掌心
浏览 207回答 3
3回答

浮云间

添加文档完整的 jquery 处理程序:$(document).ready(function(){&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; showCollectorDialog();});这将在文档完全加载后立即运行。

ITMISS

在这里,您可以像这样使用 jquery 来完成它。您可以将它放在 html 文件的末尾。还可以在 html 文件的脚本标记中包含 jquery cdn。$(document).ready ( function(){&nbsp; alert('hello world');});或者你可以这样做function functionName() {&nbsp; &nbsp; alert('hello world');}window.onload = functionName;

墨色风雨

寻找一个简单的答案,现有的谷歌没有任何作用。不需要自定义触发器。把它放到你的 html 头中,它会触发表单,我刚刚测试过;-)<script type="text/javascript">setTimeout(function() {$('#atlwdg-trigger').trigger('click');},100);</script>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答