The best way to add an IFrame element to using Javascript is to find:
- < Li> The user is completely hidden.
- The page was created after it was fully loaded. That means that the user should be completely disputed and should not affect the loading of images and other scripts in any way.
You can add a hidden
iframelike this:var iframe = document .createElement ('iframe'); Iframe.style.display = "none"; Iframe.src = / * here your url * /; Document.body.appendChild (iframe);If you need to do this on page load, you can put the corresponding code in a script tag at the end of your document, or hook it through the
window Canloadevent (window.onload = yourFunction;), thoughwindowloadevent It's too late to load the page process and of course, like many things that involve JavaScript on browsers, If you use RE, like ,,, or, you can make your life a little easier, because it can smooth the difference in the browser (it has been said, the code above will be familiar with any browser I know The library will usually present a way to do things when the page is loaded, but thewindowloadusually returns the JQueryreadyfunction provided Does; Prototypedom: loadedprovides the event; e.t.c.For example, if you put it at the end of your
bodytag, then it is loaded after everything and others are all loaded Images,windowsloaddoes not occur until all images are loaded):& lt; Script type = 'text / javascript' & gt; Window.onload = function () {var iframe = document.createElement ('iframe'); Iframe.style.display = "none"; Iframe.src = / * here your url * /; Document.body.appendChild (iframe); }; & Lt; / Script & gt;
Comments
Post a Comment