Search results for 'IE'. 2 post(s) found.
- 2009/08/28 To get web browser capability
- 2008/05/03 IFRAME Auto Resize in IE, FireFox by Javascript (13)
Now a days, there are four major web browsers: Microsoft Internet Explorer, Mozilla Firefox, Safari, and Opera. But they have the different features not compatible with other browsers. So programmers should pay attention when implement javascript application.
Here's the javascript based Browser Capability check application. This will be very helpful if you are trying to develop global services.
<script type="text/javascript">
// <![CDATA[
var modern = Boolean((( !!document.all === true && !!!document.getElementById ) ? 0 : 1 ));
var xCapabilitIEs = ( function( e ) {
var e = (( e ) ? eval( e ) : window.event );
var xTable = 0;
var count = 1;
var xElem = null;
var xCell = null;
var xDivID = "showCapabilitIEs";
var xDiv = (( modern ) ? document.getElementsByTagName( "div" )[ xDivID ] : document.all.tags( "div" )[ xDivID ] );
tableX = (( modern ) ? xDiv.getElementsByTagName( "table" ) : xDiv.all.tags("table").item( 0 ));
(( tableX[ 0 ] ) ? xDiv.removeChild( tableX[ 0 ] ) : tableX );
delete tableX;
if ( "createElement" in document )
{
xCell = ( function( row, text )
{
var xCel = row.insertCell( -1 );
return xCel.appendChild( document.createTextNode( text ));
} );
xElem = ( function( element )
{
return document.createElement( element );
} );
xTable = xElem( "table" );
var xTHead = xTable.createTHead();
var xRow = xTHead.insertRow( -1 );
var xLabel = [ "#", "Property", "Value", "Type" ];
var xLen = xLabel.length;
for ( i = 0; i < xLen; i++ )
{
xCell( xRow, xLabel[ i ] );
}
delete i;
var xTBody = xElem( "tbody" );
xTable.appendChild( xTBody );
for ( prop in e )
{
xRow = xTBody.insertRow( -1 );
xCell( xRow, count );
xCell( xRow, prop );
xCell( xRow, e[ prop ] );
xCell( xRow, typeof( e[ prop ] ));
xRow.lastChild.style.textAlign = "center";
++count;
}
delete prop;
xDiv.appendChild( xTable );
return;
}
alert( "Your browser is not capable of handling this type of script! You'll need to wait for my next version.\n- essential", "http://www.strcpy.com" );
return false;
} );
window.onload = function( event )
{
var xSel = (( modern ) ? document.getElementById( "browser" ) : document.all.browser );
xSel.onchange = ( function( event )
{
xCapabilitIEs( this.value );
} );
xCapabilitIEs( event );
}
// ]]>
</script>
<body>
<div id="content">
<div id="main">
<div class="tube" style="border-bottom : none; clear: both;">
<select id="browser" name="browser" size="1">
<option value="event" selected="selected">- EVENT Objects -</option>
<option value="window">- WINDOW Objects -</option>
<option value="document">- DOCUMENT Objects -</option>
<option value="navigator">- NAVIGATOR Objects -</option></select>
</div>
<div class="tube" id="showCapabilitIEs"></div>
</div>
</div>
</body>
// <![CDATA[
var modern = Boolean((( !!document.all === true && !!!document.getElementById ) ? 0 : 1 ));
var xCapabilitIEs = ( function( e ) {
var e = (( e ) ? eval( e ) : window.event );
var xTable = 0;
var count = 1;
var xElem = null;
var xCell = null;
var xDivID = "showCapabilitIEs";
var xDiv = (( modern ) ? document.getElementsByTagName( "div" )[ xDivID ] : document.all.tags( "div" )[ xDivID ] );
tableX = (( modern ) ? xDiv.getElementsByTagName( "table" ) : xDiv.all.tags("table").item( 0 ));
(( tableX[ 0 ] ) ? xDiv.removeChild( tableX[ 0 ] ) : tableX );
delete tableX;
if ( "createElement" in document )
{
xCell = ( function( row, text )
{
var xCel = row.insertCell( -1 );
return xCel.appendChild( document.createTextNode( text ));
} );
xElem = ( function( element )
{
return document.createElement( element );
} );
xTable = xElem( "table" );
var xTHead = xTable.createTHead();
var xRow = xTHead.insertRow( -1 );
var xLabel = [ "#", "Property", "Value", "Type" ];
var xLen = xLabel.length;
for ( i = 0; i < xLen; i++ )
{
xCell( xRow, xLabel[ i ] );
}
delete i;
var xTBody = xElem( "tbody" );
xTable.appendChild( xTBody );
for ( prop in e )
{
xRow = xTBody.insertRow( -1 );
xCell( xRow, count );
xCell( xRow, prop );
xCell( xRow, e[ prop ] );
xCell( xRow, typeof( e[ prop ] ));
xRow.lastChild.style.textAlign = "center";
++count;
}
delete prop;
xDiv.appendChild( xTable );
return;
}
alert( "Your browser is not capable of handling this type of script! You'll need to wait for my next version.\n- essential", "http://www.strcpy.com" );
return false;
} );
window.onload = function( event )
{
var xSel = (( modern ) ? document.getElementById( "browser" ) : document.all.browser );
xSel.onchange = ( function( event )
{
xCapabilitIEs( this.value );
} );
xCapabilitIEs( event );
}
// ]]>
</script>
<body>
<div id="content">
<div id="main">
<div class="tube" style="border-bottom : none; clear: both;">
<select id="browser" name="browser" size="1">
<option value="event" selected="selected">- EVENT Objects -</option>
<option value="window">- WINDOW Objects -</option>
<option value="document">- DOCUMENT Objects -</option>
<option value="navigator">- NAVIGATOR Objects -</option></select>
</div>
<div class="tube" id="showCapabilitIEs"></div>
</div>
</div>
</body>
Another posts included in "HTML, Javascript"
| Javascript based query parser for AJAX application (0) | 2009/08/28 |
| Displays the html tags without rendering on a webpage (0) | 2009/08/28 |
| To hide/show area of web page without re-loading a page (0) | 2009/08/28 |
| Photo thumbnail viewer implement in javascript (0) | 2009/08/28 |
| Javascript Confirmation (0) | 2009/08/22 |
| Javascript Prompts (0) | 2009/08/22 |
| How to know browser version in javascript ? (0) | 2009/08/22 |
| How to know the browser name in Javascript ? (0) | 2009/08/22 |
Trackback : Cannot send a trackbact to this post.
2008/05/03 08:39
IFRAME Auto Resize in IE, FireFox by Javascript
2008/05/03 08:39 in HTML, Javascript

Here's the simple iframe auto-resize example working on IE, and FireFox.
<iframe id='ifrm'
frameborder=0
width=100%
height=450
scrolling=no
src='http://kurapa.com'
></iframe>
<script language='javascript'>
function getDocHeight(doc)
{
var docHt = 0, sh, oh;
if (doc.height)
{
docHt = doc.height;
}
else if (doc.body)
{
if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
if (sh && oh) docHt = Math.max(sh, oh);
}
return docHt;
}
frameborder=0
width=100%
height=450
scrolling=no
src='http://kurapa.com'
></iframe>
<script language='javascript'>
function getDocHeight(doc)
{
var docHt = 0, sh, oh;
if (doc.height)
{
docHt = doc.height;
}
else if (doc.body)
{
if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
if (sh && oh) docHt = Math.max(sh, oh);
}
return docHt;
}
var iframeEl = window.document.getElementById? window.document.getElementById('ifrm'): document.all? document.all['ifrm']: null;
if (docHt != iframeEl.style.height) iframeEl.style.height = docHt + 'px';
}
else
{ // FireFox
var docHt = window.document.getElementById('ifrm').contentDocument.height;
window.document.getElementById('ifrm').style.height = docHt + 'px';
}
}
}
else
{ // FireFox
var docHt = window.document.getElementById('ifrm').contentDocument.height;
window.document.getElementById('ifrm').style.height = docHt + 'px';
}
}
function getRetry()
{
getReSize();
setTimeout('getRetry()',500);
}
getRetry();
</script>
{
getReSize();
setTimeout('getRetry()',500);
}
getRetry();
</script>
Another posts included in "HTML, Javascript"
| Clipboard copy function working (0) | 2008/10/17 |
| How to find the ip address of a client machine from a web application? (0) | 2009/03/21 |
| Simple RSS Reader based on javascript (0) | 2009/07/01 |
| How to include Javascript from anonther ? (0) | 2008/01/25 |
| Javascript based Browser Sniffing (0) | 2008/01/25 |
| Javascript based Regular Expression Tester (0) | 2008/01/15 |
| Two useful string functions - substr & substring (0) | 2008/01/15 |
| Is there URLEncode function in Javascript ? (0) | 2007/10/11 |
Prev

Rss Feed