Reputation: 901
<html>
<script>
document.write("<iframe id='theframe' src='http://www.website.com?testvr=" + testvr + " height='900' width='500'></iframe>");
</script>
</html>
The iframe is added, but at 500 x 150 and not at 900 x 500. This sized fine when the iframe was inside the body tags and only does this when using document.write. Why?
Upvotes: 0
Views: 48
Reputation: 14094
first of all, the correct way to apply styling is with the style attribute.
<iframe id='theframe' src='yourComplexSrc' style='height:900px; width:500px;'></iframe>
Best Practice: separate your styling from your markup. (style should go to a different stylesheet file)
but, the problem with your code is that after the src
value, you don't have a closing tag.
so eventually, this should work:
document.write("<iframe id='theframe' src='http://www.website.com?testvr=" + testvr + "' height='900' width='500'></iframe>");
Upvotes: 2