The function print () {
The debugger.
Var iframeLength=document. GetElementsByTagName (" iframe "). The length;
Var iframe_start=0;
$(" iframe ".) each (function () {
Var SRC=https://bbs.csdn.net/topics/$(this). Attr (" SRC ");
$(this) onl oad=function () {
Iframe_start + +;
The console. The info (iframe_start);
If (iframe_start==iframeLength) {
Window. The print ();
}
}
});
}
The function print2 () {
The debugger.
Var iframes=document. GetElementsByTagName (" iframe ");
For (var I=0; I & lt; Iframes. Length; I++) {
Var iframeId=iframes [I]. Id;
Var currentIframe=document. GetElementById (iframeId);
If (currentIframe. AttachEvent) {
CurrentIframe. AttachEvent (onload, function () {
//wait for the iframe loaded
});
continue;
} else {
CurrentIframe. onl oad=function () {
Window. The print ();//the iframe loaded
}
}
}
}
CodePudding user response:
The function print () {The debugger.
Var iframeLength=document. GetElementsByTagName (" iframe "). The length;
Var iframe_start=0;
$(" iframe ".) each (function () {
Var SRC=https://bbs.csdn.net/topics/$(this). Attr (" SRC ");
/* $(this). Ready (function () {
Iframe_start + +;
The console. The log (iframe_start, 'iframe_start);
If (iframe_start==iframeLength) {
Window. The print ();
}
}) */
//error in jq use ready here
$(this) onl oad=function () {
Iframe_start + +;
The console. The info (iframe_start);
If (iframe_start==iframeLength) {
Window. The print ();
}
}
});
}