i have a webpage that looks like this:
http://yoursdproperty.com/index2.php?option=com_jumi&fileid=3&Itemid=11
i want the page to be the same size as the dimensions of the little form on the page.
is there something i can modify in this code of the page?
<div id="mlcalc-w1">
<div id="mlcalc-w2">
<div id="mlcalc-w3">
<div id="mlcalc-w4">
<div id="mlcalc-w5">
<link rel="stylesheet" type="text/css" media="screen,projection" href="http://www.mortgageloan.com/sites/all/themes/mortgageloan/css/tool/mlcalc-inline.css">
<div id="mlcalc-pres">
<h2 id="mlcalc-head">
<em>19 Mortgage Calculators</em> <em><a href="http://www.mortgageloan.com/widgets/#tool-num-4" rel="nofollow" target="_blank">Get this Widget</a><span></span></em>
</h2><iframe id="mlcalc-calc" src="http://www.mortgageloan.com/tool/mortgage/mortgage-calculator-package-content" scrolling="no" border="0" frameborder="0"></ifr开发者_Python百科ame>
<p id="mlcalc-footer">
Related Resource: <a href="http://www.mortgageloan.com/">Refinance & Mortgage Rates</a>. Calculator © MortgageLoan.com.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
You could use JavaScript to get the computed height and width of the element that you want to resize to and pass them to the window.resizeTo
method.
A simple example:
This code courtesy of Robert Nyman:
function getStyle(oElm, strCssRule){
var strValue = "";
if(document.defaultView && document.defaultView.getComputedStyle){
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
}
else if(oElm.currentStyle){
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
return p1.toUpperCase();
});
strValue = oElm.currentStyle[strCssRule];
}
return strValue;
}
Now for my code:
window.onload = function() {
var element = document.getElementById( 'micalc-calc' );
var width = getStyle( element, 'width' );
var height = getStyle( element, 'height' );
window.resizeTo( parseInt( height ), parseInt( width ) );
};
Its probably worth noting that it's generally considered a good idea not to resize a browser window via JavaScript, or any way after the window is created. The main reason being that someone may have opened the page in a new tab and you're then resizing all their pages. Rather, have the link that opens the window do so with a size set for it.
精彩评论