如何调用这段js代码让其重新执行一次?
代码是在页面加载的时候执行的,如何通过js调用能让这段js代码重新执行一次?<scripttype="text/javascript">(function(win,doc...
代码是在页面加载的时候执行的,如何通过js调用能让这段js代码重新执行一次?
<script type="text/javascript">
(function (win, doc) {
var s = doc.createElement("script"),
h = doc.getElementsByTagName("head")[0];
if (!win.alimamatk_show) {
s.charset = "gbk";
s.async = true;
s.src = "tkapi.js";
h.insertBefore(s, h.firstChild);
};
var o = {
pid: "123",
};
win.alimamatk_onload = win.alimamatk_onload || [];
win.alimamatk_onload.push(o);
})(window, document);
</script>
一楼方法修改后的代码,调用方法:reCall(window, document); . 追问有字数限制,一楼看看正确不?
<script type="text/javascript">
function reCall(win,doc){
if(!win) win = window;
if(!doc) doc = document;
var s = doc.createElement("script"),
h = doc.getElementsByTagName("head")[0];
if (!win.alimamatk_show) {
s.charset = "gbk";
s.async = true;
s.src = "tkapi.js";
h.insertBefore(s, h.firstChild);
};
var o = {
pid: "123",
};
win.alimamatk_onload = win.alimamatk_onload || [];
win.alimamatk_onload.push(o);
}
</script> 展开
<script type="text/javascript">
(function (win, doc) {
var s = doc.createElement("script"),
h = doc.getElementsByTagName("head")[0];
if (!win.alimamatk_show) {
s.charset = "gbk";
s.async = true;
s.src = "tkapi.js";
h.insertBefore(s, h.firstChild);
};
var o = {
pid: "123",
};
win.alimamatk_onload = win.alimamatk_onload || [];
win.alimamatk_onload.push(o);
})(window, document);
</script>
一楼方法修改后的代码,调用方法:reCall(window, document); . 追问有字数限制,一楼看看正确不?
<script type="text/javascript">
function reCall(win,doc){
if(!win) win = window;
if(!doc) doc = document;
var s = doc.createElement("script"),
h = doc.getElementsByTagName("head")[0];
if (!win.alimamatk_show) {
s.charset = "gbk";
s.async = true;
s.src = "tkapi.js";
h.insertBefore(s, h.firstChild);
};
var o = {
pid: "123",
};
win.alimamatk_onload = win.alimamatk_onload || [];
win.alimamatk_onload.push(o);
}
</script> 展开
若以下回答无法解决问题,邀请你更新回答
展开全部
<script type="text/javascript">
(function (win, doc) {
reCall(win,doc);
window.setTimeout("reCall",2000);//页面加载完成后延迟2秒执行
})(window, document);
function reCall(win,doc){
if(!win) win = window;
if(!doc) doc = document;
var s = doc.createElement("script"),
h = doc.getElementsByTagName("head")[0];
if (!win.alimamatk_show) {
s.charset = "gbk";
s.async = true;
s.src = "tkapi.js";
h.insertBefore(s, h.firstChild);
};
var o = {
pid: "123",
};
win.alimamatk_onload = win.alimamatk_onload || [];
win.alimamatk_onload.push(o);
}
</script>
(function (win, doc) {
reCall(win,doc);
window.setTimeout("reCall",2000);//页面加载完成后延迟2秒执行
})(window, document);
function reCall(win,doc){
if(!win) win = window;
if(!doc) doc = document;
var s = doc.createElement("script"),
h = doc.getElementsByTagName("head")[0];
if (!win.alimamatk_show) {
s.charset = "gbk";
s.async = true;
s.src = "tkapi.js";
h.insertBefore(s, h.firstChild);
};
var o = {
pid: "123",
};
win.alimamatk_onload = win.alimamatk_onload || [];
win.alimamatk_onload.push(o);
}
</script>
追问
谢谢,我想随时让代码运行这样改行不行? 想让代码运行的时候调用reCall(window, document); 就可以了.
追答
可以的
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询