ifstream in only HTML Javascript without Jquery

问题描述 投票:0回答:1

在我的静态HTML页面中,我无法使用Jquery。我希望有一个按钮可以在iframe中加载网页。

<input type="button" value="See" id="but" onclick="document.getElementById('iframe').innerHTML='Hello'"/> <iframe id="iframe" name="myIframe" width="90%" height="90%"></iframe>

没有任何反应。

ifstream
1个回答
0
投票

iframe有来源,而不是innerHtml

document.getElementById('but').addEventListener('click', function() {
  document.getElementById('iframe').src = "data:text/html;charset=utf-8," + escape('Hello')
})
<input type="button" value="See" id="but" />
<iframe id="iframe" name="myIframe" width="90%" height="90%"></iframe>
© www.soinside.com 2019 - 2024. All rights reserved.