我綁定如果我通過了jQuery相當於改變像這樣爲什麼windows.onload被執行多次?
// It's a little more complex than this, I analyze if there is any other function
// attached but for the sake of the question it's ok, this behaves the same.
window.onload = myfunction;
的Onload window.onload事件被觸發兩次我的本地機器上的生產服務器
在幾次
$jQuery(window).load(myfunction);
它的行爲與預期(只執行一次)。
能不能幫我瞭解可能的原因它不工作作爲第一選擇應該?
謝謝!
稱爲鑑於您的編輯,有沒有足夠的上下文來猜測爲什麼該方法會被調用兩次的任何可能的原因。請包括任何其他參考加載事件和/或'myfunction'。 – Nicole 2011-06-02 20:07:16
你在這裏展示的是完全標準的。我們需要查看代碼的其餘部分,以查看問題所在。 – squidbe 2011-06-02 20:08:12
@Timmy:看起來你已經「示範」了你的問題。除非你用* actual *代碼修改你的問題,否則沒有理由保持這種狀態。 – Jeremy 2011-06-02 20:12:12