Reputation: 114
Using the javascript onresize, only works one time. I need it to work multiple times. Here is my code:
var hh = window.outerHeight;
var ww = window.outerWidth;
document.write("<iframe src='http://www.example.com' align='left' width='" + ww + "px' height='600px' frameborder='0'></iframe>");
window.onresize = function (){
hh = window.outerHeight;
ww = window.outerWidth;
document.write("<iframe src='http://www.example.com' align='left' width='" + ww + "px' height='600px' frameborder='0'></iframe>");
}
Upvotes: 0
Views: 374
Reputation: 123
You are creating a new iframe every time. It is better to just select the one that has already been made.
var hh = window.outerHeight;
var ww = window.outerWidth;
document.write("<iframe src='http://www.example.com' align='left' width='" + ww + "px' height='600px' frameborder='0'></iframe>");
window.onresize = function (){
hh = window.outerHeight;
ww = window.outerWidth;
document.querySelector("iframe").setAttribute('width', ww+'px');
}
Upvotes: 1