[英]window.onresize not working when call at different js files in a same html file
I have used the window.reize function twice in a same file from different server , but window.resize function is not working. 我已经在来自不同服务器的同一文件中两次使用window.reize函数,但是window.resize函数不起作用。 Only one code get working.
只有一个代码起作用。 I have an HTML code like below
我有如下的HTML代码
<script language="javascript" type="text/javascript" src="http://localhost/workspace/appldp_27_03_17/show-ads.js"></script>
<script language="javascript" type="text/javascript" src="http://appldp.com/show-ads.js"></script>
I run the above html file in my localhost directory. 我在本地主机目录中运行上述html文件。 Also the show-ads.js file has a code in it
另外show-ads.js文件中也包含代码
function somethingCalledFunction(currentURL){
window.onresize = function(event) {
console.log(currentURL);
}
}
It only console the URL from the appldp.com server why it is like that. 它只控制台appldp.com服务器上的URL,原因是这样。
It only console the URL from the appldp.com server why it is like that.
它只控制台appldp.com服务器上的URL,原因是这样。
As @Teemu pointed out, the problem is that your library is loaded twice. 正如@Teemu指出的那样,问题在于您的库已加载两次。 So, the same file in memory twice.
因此,同一文件在内存中两次。 To avoid this, it overwrites the previous one and call the function you edited in the post.
为了避免这种情况,它将覆盖上一个,并调用您在帖子中编辑的函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.