窗口加载与正文加载javascript冲突

窗口加载与正文加载javascript冲突,javascript,Javascript,我的客户将我们下面的JS代码放在他的网站的中,并抱怨我们的标签没有启动。以下是来自客户端的示例代码: <html> <head> <script type="text/javascript"> function create() { try { var baseURL = "https://serv2ssl.vizury.com/analyze/analyze.php?account_id=VIZVRM1125"

我的客户将我们下面的JS代码放在他的网站的
中,并抱怨我们的标签没有启动。以下是来自客户端的示例代码:

    <html>
    <head>
    <script type="text/javascript">
    function create() {
    try {
    var baseURL = "https://serv2ssl.vizury.com/analyze/analyze.php?account_id=VIZVRM1125";
    var analyze = document.createElement("iframe");
    analyze.src = baseURL;
    var node = document.getElementsByTagName("script")[0];
    node.parentNode.insertBefore(analyze, node);
} catch (i) {
}
}
 var existing = window.onload;
window.onload = function() {
if (existing) {
    existing();
}
create();
}
  </script>
 </head>

 <body onload="javascript:clientfunction();">
 <script type="text/javascript">

function clientfunction()
{
   //client code is replcad here
   document.write("Hello testing");
}
 </script>

  </body>
 </html>

函数create(){
试一试{
var baseURL=”https://serv2ssl.vizury.com/analyze/analyze.php?account_id=VIZVRM1125";
var analyze=document.createElement(“iframe”);
analyze.src=baseURL;
var node=document.getElementsByTagName(“脚本”)[0];
node.parentNode.insertBefore(分析,节点);
}捕获(i){
}
}
var existing=window.onload;
window.onload=函数(){
如果(现有){
现有();
}
创建();
}
函数clientfunction()
{
//客户端代码在这里是replcad
编写(“你好测试”);
}
在调用页面加载
clientfunction()
时,我们的
create()
函数没有启动


有谁能帮我解释一下为什么我们的标签没有被触发,以及这个问题的替代解决方案是什么?

复制粘贴并检查以下内容

<html>
<head>
<script type="text/javascript">
function create() {
alert("Gdfg");
try {
var baseURL = "https://serv2ssl.vizury.com/analyze/analyze.php?account_id=VIZVRM1125";
var analyze = document.createElement("iframe");
analyze.src = baseURL;
var node = document.getElementsByTagName("script")[0];
node.parentNode.insertBefore(analyze, node);
} catch (i) {
}
}

window.onload=create;
window.onload=clientfunction;
</script>
</head>

<body onload="clientfunction(); create()">
<script type="text/javascript">

function clientfunction()
{
alert("fdsfsdf");
//client code is replcad here
document.write("Hello testing");
}
</script>

</body>
</html>

函数create(){
警报(“Gdfg”);
试一试{
var baseURL=”https://serv2ssl.vizury.com/analyze/analyze.php?account_id=VIZVRM1125";
var analyze=document.createElement(“iframe”);
analyze.src=baseURL;
var node=document.getElementsByTagName(“脚本”)[0];
node.parentNode.insertBefore(分析,节点);
}捕获(i){
}
}
window.onload=create;
window.onload=clientfunction;
函数clientfunction()
{
警报(“fdsfsdf”);
//客户端代码在这里是replcad
编写(“你好测试”);
}

只有底部执行,不是吗?不,两者都可以正常工作,我正在编辑我的帖子,为您提供完整的代码。@SKV两者都可以正常工作,因为您已将它们粘贴在
标记的
onload
属性中,但这绝对是一种黑客行为。您还将丢失以前声明的任何
窗口。onload
函数,问题中的代码正在为此做出特定的努力。如果客户端的函数(或使用相同代码的其他客户端)更改其名称,会发生什么情况?请阅读更多信息