[Body] javascript Functions related to the body page. onload is triggered when the page is loaded, onresize is triggered when the page size changes, and onscroll is triggered when the scroll bar is rolled, in actual use, you do not want to add multiple trigger functions to the body, so you want to overwrite javascript as follows:
<SCRIPT language = javascript> <! -- Function load_func (){ Window. onresize = func (); Window. onscroll = func (); // func () indicates the function to be called. } // --> </SCRIPT>
<body onload="load_func()">
|
In this way, only the onload function is used in the definition of the body to call load_func () and then overwrite other page events of the body. In IE, it can be used normally, but it does not work in Firefox, after checking for a long time, I thought that this overwrite method could not be implemented for Firefox, But I occasionally found that an overwrite code can be executed in FF. I checked it carefully and found that the overwrite method was different, compare the differences between the two:
Window. onresize = func (); // only supports IE
|
Window. onresize = func; // supports IE and FF
|
In Javascript, calling a function is generally represented by the function name + parentheses. However, only the function name is used to point to the defined function, but it is not supported by adding parentheses. I still don't know the specific cause, so you need to pay attention to it in the future.
This article is from: Jedliu.cublog.cn