禁用iframe自动加载

禁用iframe自动加载

本文介绍了禁用iframe自动加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个页面的html。
我有一些页面,我打开它们在iframe中。
当我打开html页面(它包含所有页面)时,它开始加载所有iframe,页面变得如此缓慢而缓慢。
有什么办法可以禁用自动iframe加载吗?
还是有没有其他的方式来打开页面没有iframe,但仍然留在我的应用程序?
这是我的页面(在一个html中)代码的一部分:

 < html> 
< head>
< / head>
< body>
< div data-role =pageid =website>
< div data-theme =adata-role =header>
< a href =#homedata-theme =adata-role =buttondata-icon =arrow-ltitle =back-button>返回< / a>
Idan
< / div>
< div>
< / div>
< / div>
< div data-role =pageid =website1>
< div data-theme =adata-role =header>
< a href =#homedata-theme =adata-role =buttondata-icon =arrow-ltitle =back-button>返回< / a>
Idan
< / div>
< div>
< / div>
< / div>
< div data-role =pageid =website2>
< div data-theme =adata-role =header>
< a href =#homedata-theme =adata-role =buttondata-icon =arrow-ltitle =back-button>返回< / a>
Idan
< / div>
< div>
< / div>
< / div>
< / body>
< / html>


解决方案

Tom is correct,



把它放在你的html的底部,但在标签之前

 < script> 
document.getElementById(myIframe)。src =http://www.idan1.com;
< / script>

您必须将id标记添加到您的iframe并移除src

 < iframe id =myIframestyle =border:0; position:absolute; top:43px; left:0; right:0; bottom :0; width:320px; height:480px; background:white>< / iframe> 

你甚至可以看中它,并做一个onload。

i have one html with multiple pages in it. i have some pages that i open them in iframes. when i open the html page (it contains all pages in it) it starts loading all iframes and the page becomes so laggy and slowly. is there any way to disable automatic iframes load? or is there any other way to open pages without iframes but still stay in my app? this is my part of my pages (that in one html) code:

<html>
    <head>
    </head>
    <body>
        <div data-role="page" id="website">
            <div data-theme="a" data-role="header">
                <a href="#home" data-theme="a" data-role="button" data-icon="arrow-l" title="back-button">Back</a>
                    Idan
            </div>
            <div>
                <iframe src="http://www.idan.com" style="border: 0; position:absolute; top:43px; left:0; right:0; bottom:0; width:320px; height:480px; background: white"></iframe>
            </div>
        </div>
        <div data-role="page" id="website1">
            <div data-theme="a" data-role="header">
                <a href="#home" data-theme="a" data-role="button" data-icon="arrow-l" title="back-button">Back</a>
                    Idan
            </div>
            <div>
                <iframe src="http://www.idan1.com" style="border: 0; position:absolute; top:43px; left:0; right:0; bottom:0; width:320px; height:480px; background: white"></iframe>
            </div>
        </div>
        <div data-role="page" id="website2">
            <div data-theme="a" data-role="header">
                <a href="#home" data-theme="a" data-role="button" data-icon="arrow-l" title="back-button">Back</a>
                    Idan
            </div>
            <div>
                <iframe src="http://www.idan2.com" style="border: 0; position:absolute; top:43px; left:0; right:0; bottom:0; width:320px; height:480px; background: white"></iframe>
            </div>
        </div>
    </body>
    </html>
解决方案

Tom is correct,

put this at the bottom of your html, but before the tag

<script>
document.getElementById("myIframe").src = "http://www.idan1.com";
</script>

you will have to add the id tag to your iframe and remove the src

              <iframe id="myIframe" style="border: 0; position:absolute; top:43px; left:0; right:0; bottom:0; width:320px; height:480px; background: white"></iframe>

You could even get fancy, and do an set onload.

这篇关于禁用iframe自动加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:30