Today, I have nothing to worry about. I wrote an IFRAME adaptive height test and failed to bind the IFRAME onload event in the script.
Function suitself2 (myifrobj) {<br/> myifrobj = NULL? Document. getelementbyid ('myifr _ 2'): myifrobj; </P> <p> If (myifrobj = NULL) Alert ('suitself2 myifrobj is null '); </P> <p> var myifrbody = myifrobj.content?#doc ument. body; </P> <p> If (myifrbody = NULL) {// If the IFRAME page is not correctly loaded, the body cannot be obtained, set a height by yourself <br/> alert ('suitself2 myifrbody is null'); <br/> myifrobj. style. height = 600; <br/>}</P> <p> If (myifrobj. contentWindow. attachevent) {<br/> alert ('assad1'); <br/> myifrobj. contentWindow. attachevent ("onLoad", function () {// ie <br/> suitself (myifrobj); <br/> alert ('attachevent'); <br/> }); </P> <p> myifrobj. contentWindow. attachevent ("onscroll", function () {<br/> suitself (myifrobj); <br/> alert ('onscroll '); <br/> }); </P> <p >}< br/> else if (myifrobj. contentWindow. addeventlistener) {// Mozilla, Firefox <br/> alert ('assad2'); <br/> myifrobj. contentWindow. addeventlistener ("LOAD", function () {<br/> suitself (myifrobj); <br/> alert ('addeventlistener '); <br/>}, false ); <br/>}< br/> else {<br/> alert ('assad3'); <br/> var oldonload = myifrobj. contentWindow. onload; <br/> myifrobj. contentWindow. onload = new function () {<br/> If (typeof oldonload = 'function') {<br/> oldonload (); <br/>}< br/> suitself (myifrobj); <br/> alert ('onload'); <br/> }; <br/>}</P> <p >}< br/>
Put myifrobj. contentWindow. attachevent ("onLoad", function () {// IE
Suitself (myifrobj );
Alert ('tachevent ');
});
Change to myifrobj. contentWindow. attachevent ("onLoad", new function () {// IE
Suitself (myifrobj );
Alert ('tachevent ');
});
Pay attention to the red part. I found that the height of IFRAME is adaptive.
After checking function () {} and new function () {}, we found that the former typeof is function, and the latter is object.
When an onscroll event is added later, alert ('onscroll ') is executed in the pop-up page. At this time, I felt a bit wrong,
Add the script new function () {alert ('1232asdasd') ;}, as expected, alert ('1232asdasd'); executed, and executed before the page is displayed.
From this result, function () {} declares and defines a method. New Function () {} is a declaration, defines a method object, and executes this method object, this method object cannot recognize the following elements.