Test environment:
Windows XP SP3
Safari 4.0.5
Safari 5.0
Create an HTML file with the following content:
Drag this file into safari and Safari will be "dead "......
Cause: if the initial src attribute is null or the IFRAME element of "about: blank", Safari will die if its onload event contains functions such as alert, confirm, and prompt.
Solution: Do not leave the src attribute blank, or do
unexpected results. However, when we try to set $ (document). ready () {}, this interface will prepare the correct actions available earlier.Use $ (document ). ready () {} is generally better than the onload event handler, but it must be clear that the support file may not be completed yet, therefore, attributes such as the image height and width are not necessarily valid at this time.
Onload events are g
execution. Using jquery ready can alleviate this problem.
We should note that jquery's ready refers to executing the specified function after the DOM model of the page is loaded. $ (Document) is often used ). ready () to replace window. onload is because it is executed after the dom model is loaded, while window. onload is executed only after the dom element is fully loaded.
B. About document.
Here, the result is assigned to him. The above is executed on IE, And the execution on Firefox is the correct result, that is, 1 --> -- 2> loading the body. The output result is what we want,
But IE is the above result 1 -- load the body, 2 is not displayed, the result is still null, It is speechless. In addition, an error is reported during debugging.Window. onload = f; this sentence has not been implemented yet.
;Jsp:include>9 Body> Ten HTML>This is body.jsp source code1 @ Page Language="Java"Import="java.util.*"pageencoding="gb2312"%>2 HTML>3 Head>4 title>Body pagetitle>5 Head>6 Body>7 P>This is the Body page.8 Body> 9 HTML>Then look at the effect after running, open the F12 development toolWe only see the If you find a problem, you need a solution. In fact, we found that onload is actually the windon.onload of another way of expression, the principle
Perfect Method for judging whether IFRAME is loaded
IE supports IFRAME onload events, but they are invisible and need to be registered through attachevent.
The second method is more perfect than the first method (using readystatechange), because the readystatechange event has some potential problems compared with the load event.
I feel that this is not completely accurate, and it has caused me a lot of trouble. I can see from its code that in the real
Window onload and IMG onload eventsTypically, Window.onload is run after the DOM is loaded.and IMG is the OnLoad event that runs it when the picture is loaded. Based on whether IMG SRC is loaded.So. Look at the following code:Note: The top 6.png itself to find the picture to replace on.The above code will not pop up 1. Since Window.onload already contains the
Determines whether window. onload is used multiple times and window. onload
Window. onload must have been used by everyone. It is executed during window loading. How can we determine if window. onload is used multiple times? Take a look at the following code
Can windowonload in js link external js files be written
Window. onload User Guide, window. onload
Javascript script code on a webpage can be executed only after the document is loaded. Otherwise, the object cannot be obtained. To avoid this, you can use the following two methods:
1. Place the script code at the low end of the Web page. when running the script code, you can ensure that the object to be operated has been loaded.2. Run the script code through windo
How to handle multiple window. onload events and multiple window. onload events at the same time
Sometimes when other js is referenced, its js uses the window. onload event. In this way, the onload event of the introduced page may not be executed. How can we run both of them? Besides writing two methods together, ther
Window onload and IMG onload eventsTypically, Window.onload is executed after the DOM is loaded. IMG is the onload event that finishes loading the image and executes it, depending on whether the IMG SRC is loaded.So, look at the following code:Note: The top 6.png itself to find the picture to replace on.The above code will not pop up 1 because window.onload alrea
Transfer from http://topic.csdn.net/u/20100608/14/aa805ed6-0820-47c7-b866-6dd93d90ea67.html (10 floor)
Scenario 1: The function specified by window. onload is anonymous, and only the latter is executed, and the action is the latter action. For example:
---- Display: ACDCase 2: If the function specified by window. onload is not anonymous, It will be executed. The former is prior to the latter. For example:
You may have encountered this situation, that is, the onload event in the body may be affected after window. onload is used in JS Code. You can write all the data in the body or in window. onload, but this is not very convenient. Sometimes we need to use both of them at the same time. In this case, we need to use window. attachevent and window. addeventlistener t
Alert prompt box open-source framework Tiny-Alert and zeptotiny-alert based on ZeptoProject homepage: http://shootyou.github.io/tiny-alert/?is tiny-alert?
This is a prompt box plug-in based on Zepto, which can be used on mobile terminals for better results. It is designed as
Window. onload is often used for projects,
The usage is as follows:
Function func () {alert ("this is window onload event! "); Return ;}
Window. onload = func;
Or:
Window. onload = function () {alert ("this is window
The usage is as follows:
Function func () {alert ("this is window onload event! "); Return ;}
Window. onload = func;
Or:
Window. onload = function () {alert ("this is window onload event! "); Return ;}
However, window.
Window. onload is often used for projects, but window. onload cannot load multiple functions at the same time. The usage is as follows:
Function func () {alert ("this is window onload event! "); Return ;}
Window. onload = func;
Or:
Window.
Page load complete There are two kinds of events, one is ready, that the document structure has been loaded complete (not including pictures and other non-text media files), the second is the onload, indicating that the page contains pictures and other files, such as all the elements are loaded to complete. (can be said: Ready before the onload loading!!! )General style control, such as picture size control
webpage is loaded (including images) before all Dom structures on the webpage are drawn, the content that can be associated with DOM elements is not loaded. You cannot write multiple codes at the same time. The following Code is incorrect. run: window. onload = function () { alert ("text1"); }; window. onload = function () {
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.