Javascript 单击“需要加载的帧”

Javascript 单击“需要加载的帧”,javascript,jquery,typescript,jquery-ui,Javascript,Jquery,Typescript,Jquery Ui,当自动加载页面时,iframe也会加载,它不必这样做 当我点击按钮时,那个么只有iframe需要加载,但在iframe中有url 你能给我举个JSFIDLE的例子吗 <input type="button">Load</input> <div class="copy"> <iframe id="font" src="${SubscriptionUrl }" frameborder="0" height="500px" width="100%"&g

当自动加载页面时,iframe也会加载,它不必这样做 当我点击按钮时,那个么只有iframe需要加载,但在iframe中有url

你能给我举个JSFIDLE的例子吗

<input type="button">Load</input>

 <div class="copy">
  <iframe id="font" src="${SubscriptionUrl }" frameborder="0" height="500px" width="100%"></iframe>
</div>
加载

您可以隐藏iframe onload,然后在单击时显示

<button id="btnLoad" type="button">Load</button>

<div class="copy">
    <iframe style="display:none;" id="font" src="${SubscriptionUrl }" frameborder="0" height="500px" width="100%"></iframe>
</div>

<script>
        const btnLoad= document.getElementById('btnLoad');

        btnLoad.addEventListener("click", function(){
             document.getElementById("font").style.display = "block";
        });

</script>
加载
const btnLoad=document.getElementById('btnLoad');
btnLoad.addEventListener(“单击”,函数(){
document.getElementById(“font”).style.display=“block”;
});
使用

  • 设置

  • 演示
    html,
    身体{
    身高:100%;
    宽度:100%;
    字体:400 16px/1.5控制台;
    }
    .btn{
    文本对齐:居中;
    }
    a{
    文字装饰:无;
    }
    
    

    检查一下

    你到底在问什么?我的最佳猜测是,您希望在单击按钮时将iframe加载到页面中(这是您的代码所建议的)。我说的对吗?您是否尝试过更改iFrame的src属性(单击)而不是加载新页面?
    Initially set one attribute to iframe .While clicking button take the attribute from the iframe and set that to iframe src.