javascript - What is window.onpaint? - Stack Overflow

Someone remended here that window.onpaint be used to run some javascript before page load. I've ne

Someone remended here that window.onpaint be used to run some javascript before page load. I've never actually seen this before, could someone explain its usage/usefulness?

Someone remended here that window.onpaint be used to run some javascript before page load. I've never actually seen this before, could someone explain its usage/usefulness?

Share Improve this question edited May 23, 2017 at 11:48 CommunityBot 11 silver badge asked May 14, 2014 at 14:16 Kyle MarimonKyle Marimon 6166 silver badges11 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

From the MDN :

onpaint doesn't work currently, and it is questionable whether this event is going to work at all, see bug 239074.

So the usefulness is zero.

It might depend on your exact use case but if you want to run a script "before page load", the simplest solution is probably to put it in the head.

[UPDATE 2025]

Looking at MDN, there is no reference to any paint event existing on the window object and there is no reference to any window.onpaint method, even in the list of deprecated methods. After searching on the internet, there is no reference of such method, except the two Stackoverflow questions (this one and the one mentioned in the question) and the Mozilla discussion mentioned by Kyle Marimon.

The HTML5/DOM window specification (https://www.w3/TR/2008/WD-html5-20080610/web-browsers.html#window) has no reference to such event or function.

Last but not least, window.onpaint is never called automatically by the browser. A simple test can be done:

    <script>
        window.onpaint = () => {
            console.log("hello stackoverflow from window.onpaint()")
        }
    </script>

The snippet above won't log anything into the console.

In other words, feel free to define window.onpaint but don't expect this function to be called when initializing the DOM.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743704960a4493209.html

相关推荐

  • javascript - What is window.onpaint? - Stack Overflow

    Someone remended here that window.onpaint be used to run some javascript before page load. I've ne

    6天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信