How To Add Functions To Javascript onload Over Third Party Scripts; Playing Nice如何添加功能的JavaScript的onload超过三分之一党的脚本;发挥不错
As a javascript developer using onload often you will find that other script authors too love to use onload.作为一个JavaScript的开发人员使用的onload往往你会发现其他脚本作者太爱使用的onload 。 Unfortunately onload accepts a function name and your reassigning will prevent others from using onload.可惜的onload接受一个函数的名称和您的重新分配将防止其他人使用的onload 。 Here is a script which allows you to use onload even when others have used it and without breaking their script.这里是一个脚本,这可以让你用的onload ,甚至当别人都用它,并没有打破他们的脚本。
The key idea is that you should be able to stack your function(s) above / below existing function call.关键的想法是,你应该可以堆叠您的函数( )以上/下面现有的函数调用。 Let’s look at the sample code below:让我们看看示例代码如下:
I think I have well commented the code to make the script self-explanatory, but feel to ask questions.我想我已经好评论的代码,使脚本自我解释性,但觉得发问。 The code has been tested on Firefox, Internet Explorer and Opera.代码已经过测试,在Firefox , Internet Explorer和歌剧。
Filed under提起下 Browser浏览器 , , Firefox火狐 , , Headline News头条新闻 , , How To如何 , , Internet Explorer Internet Explorer中 , , Javascript JavaScript的 , , Programming编程 , , Web网页 , , Web 2.0 Web 2.0的 , , Web Services Web服务 | |
| |
RSS 2.0 2.0 | |
Trackback Trackback跟踪 this Article |此文章|
Email this Article电子邮件此文章
You may also like to read您也可以想读 |





February 7th, 2007 at 10:34 pm 2007年2月7日在下午10时34分
Where is the sample code?哪里是示例代码?
February 8th, 2007 at 1:08 am 2007年2月8日在上午01时08分
hi there,喜有,
I don’t see any code — I use firefox 1.5.x on windows.我看不出有任何的代码-我使用F irefox1 .5.x在W indows上使用。
Thank you,谢谢您,
BR,溴
~A 〜一
February 8th, 2007 at 3:09 am 2007年2月8日在上午03时09分
Thanks for the catch.感谢的渔获量。 I forgot to escape the <’s and >’s我忘记了逃避<奇摩和“ >奇摩
April 30th, 2007 at 5:44 pm 2007年4月30日在下午5时44分
Thanks for the script!感谢脚本!
October 26th, 2007 at 6:30 am 2007年10月26日在上午06时30分
Great idea.的伟大构想。 I created a function, addEventHandler, that simplifies adding this technique to new Javascripts.我创建了一个功能, addeventhandler ,简化了加入这一技术的新javascripts 。
Thanks for addressing this issue.感谢为解决这一问题。 It was a recent concern of mine.这是一个最近关注的矿井。