<title> Get page Width </title>
<script src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type= "Text/javascript" ></ Script>
<script type= "Text/javascript" >
$.format = function (source, params) {
if (arguments.length = 1)
return function () {
var args = $.makearray (arguments);
Args.unshift (source);
Return $.format.apply (this, args);
};
if (Arguments.length > 2 && params.constructor!= Array) {
params = $.makearray (arguments). Slice (1);
}
if (params.constructor!= Array) {
params = [params];
}
$.each (params, function (i, n) {
Source = Source.replace (New RegExp ("\\{" + i + "\}", "G"), n);
});
return source;
};
/*------------above is the string format function----------------* *
$ (document). Ready (function () {
$ ("button"). Click (function () {
var d=$ ("#div1");
var txt = "";
TXT + + $.format ("width (): {0}</br>", D.width ());
TXT + + $.format ("Height (): {0}</br>", D.height ());
TXT + + $.format ("Inner Width: {0}</br>", D.innerwidth ());
TXT + $.format ("Inner Height: {0}</br>", D.innerheight ());
TXT + + $.format ("Outer Width: {0}</br>", D.outerwidth ());
TXT + $.format ("Outer Height: {0}</br>", D.outerheight ());
TXT + $.format ("Outerwidth (true): {0}</br>", D.outerwidth (true));
TXT + $.format ("Outerheight (true): {0}</br>", D.outerheight (true));
TXT + + $.format ("HTML Document Width: {0}</br>", $ (document). width ());
TXT + $.format ("HTML Document Height: {0}</br>", $ (document). Height ());
txt = $.format ("Browser viewport width: {0}</br>", $ (window). width ());
txt = $.format ("Browser height: {0}</br>", $ (window). Height ());
$ ("#div1"). HTML (TXT);
});
});
</script>
<body>
<div id= "Div1" style= "height:auto;width:300px;padding:10px;margin:3px;border:1px solid Blue;background-color: LightBlue; " ></div>
<br/>
<button> Display current various sizes </button>
<p><a href= "http://4welove.taobao.com" target= "_blank" > Mobile phone bill, Q currency, game recharge </a></p>
<p>width ()-Returns the width of the element. </p>
<p>height ()-Returns the height of the element. </p>
The <p>innerwidth () method returns the width of the element, including the inner margin. </p>
The <p>innerheight () method returns the height of the element, including the inner margin. </p>
The <p>outerwidth () method returns the width of the element (including the inner margin and border). </p>
The <p>outerheight () method returns the height of the element (including the inner margin and border). </p>
The <p>outerwidth (True) method returns the width of the element, including the inner margin, border, and outer margin. </p>
The <p>outerheight (True) method returns the height of the element, including the inner margin, border, and outer margin. </p>
<p> Return Documents (HTML documents) $ (document). Height () high </p>
<p> return window (browser viewport) $ (window). Height () </p>
</body>