视口 iframe
您好,我目前正在尝试制作一个具有视口宽度和高度的 iframe。 这是代码:
document.getElementById("myframe").innerHTML="<iframe id='myframe' src='index.html' width='" + viewportwidth +"' height='" +viewportheight +"'></iframe>"
当我运行它时什么也没有显示。 (' 是')
如果您有更好的方法来做到这一点,那也会有帮助。
我尝试这样做的原因是因为我正在运行两个 jquery 扩展,并且它们相互冲突。
Hello I am currently trying to make an iframe which has the width and height of the viewport.
Here is the code:
document.getElementById("myframe").innerHTML="<iframe id='myframe' src='index.html' width='" + viewportwidth +"' height='" +viewportheight +"'></iframe>"
Nothing shows up when I run it. (& #39; is ')
If you have a better way of doing this, that would be helpful as well.
The reason I am trying to do this is because I am running two jquery extensions, and they conflict with each other.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用特殊字符
`
很可能会弄乱您的代码。只需使用转义引号,将`
替换为\"
。使用 javascript 编写 HTML 时,将 HTML 字符串放在单引号中通常比双引号更容易引号,这样您就可以像平常一样编写 HTML,而不必转义引号。Using the special character
`
is most likely messing up your code. Just use an escaped quote instead by replacing`
with\"
. When writing HTML with javascript it's often easier to put the HTML string in single quotes, rather than double quotes, so you can write the HTML as your normally would, without having to escape the quotes.