realazy


opera img onload重复执行

由于某些原因需要把函数直接放到 img 标签上的 onload 属性执行,比如:

For some reasons we have to execute the JavaScript function in the img tag’s attribute onload, e.g.

<img onload="javascript:jsFunction();" ...

开启 Opera, CPU 狂窜到 100%……

When using Opera browser, the CPU usage is up to 100%…

原来丫会重复执行 jsFunction……只好加个变量来记录是否已经执行。

Because Opera execute jsFunction repeatedly. The solution is adding an flag variable to track the function be executed or not.

Google 一下并没有发现这方面的资料,所以记下来,希望能帮助碰到这个问题的人。为了表现我的国际主义精神,特翻译了一下(至于这句,就不翻了……)。

4 Responses to “opera img onload重复执行”

  1. 北极冰仔 Says:

    还真的一直没注意过 Opera 的表现呢……

  2. 小马 Says:

    maybe:
    function jsFunction() {
    …do something…
    this.onload = null;
    }

  3. wondger Says:

    诡异~为何我这里没有这个问题~···

  4. bob_jia Says:

    我也没问题,我的版本是950

Leave a Reply


realazy (懒到死) is proudly powered by WordPress | Entries (RSS) and Comments (RSS)