加载javascript在body onload有2个功能 [英] Loading javascript in body onload with 2 functions

查看:173
本文介绍了加载javascript在body onload有2个功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在body中加载2个javascript事件/函数,如下所示:

I am trying to load 2 javascript events/functions in the body onload as follows :-

<body onLoad="getSubs(document.form1.HotelID.options[document.form1.HotelID.selectedIndex].value);getTags(document.form1.HotelID.options[document.form1.HotelID.selectedIndex].value);">

每当我使用2个函数加载时,第一个函数中止 - 但是如果我只加载一个函数

Whenever I load using 2 functions the first one aborts - but if I just load the one it works fine - am I doing something wrong is it no possible to put 2 functions within the onload?

推荐答案

只要从java脚本做,而不是,其中一个链接共享到一个注释中解释了为什么最好使用这种方法对内联属性。

Just do it from java script instead, one of the link shared into a comment explains well why it is best to use this approach over inline attributes.

<head>
<script>
document.body.onload = function() {
getSubs(...);
getTags(...);
};
</script>
</head>
<body>
...
</body>

这篇关于加载javascript在body onload有2个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆