select checkbox page load
javascript_onload_checkbox :
This javascript selects the checkbox using the indexof in pageload event
<html> <head> <script type="text/javascript"> var arr1 = "acd"; var arrval = ""; function load() { window.status="Page is loaded here"; if ((searcharray=arr1.indexOf("a"))!=-1) { arrval="its A"; callalert(); document.test.checkgroup[0].checked=true; } if ((searcharray=arr1.indexOf("b"))!=-1) { arrval="its B"; callalert(); document.test.checkgroup[1].checked=true; } if ((searcharray=arr1.indexOf("c"))!=-1) { arrval="its C"; callalert(); document.test.checkgroup[2].checked=true; } if ((searcharray=arr1.indexOf("d"))!=-1) { arrval="its D"; callalert(); document.test.checkgroup[3].checked=true; } } function clicked() { alert("Changing value manually") } function callalert() { alert (arrval); } document.write(’THE GIVEN VALUE OR ARRAY IS<br>’); document.write(arr1); </script> </head> <body onload="load()"> </body> </html> <form name="test"> A:<input type="checkbox" name="checkgroup" onclick="clicked()"/><br /> B:<input type="checkbox" name="checkgroup" onclick="clicked()"/><br /> C:<input type="checkbox" name="checkgroup" onclick="clicked()"/><br /> D:<input type="checkbox" name="checkgroup" onclick="clicked()"/><br /> </form> </html>
Browser full information javascript
To get full information on browser :
Like:
Browser name = Firefox
Full version = 2
Major version = 2
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Got a good script to achieve the above Use :
<html> <SCRIPT LANGUAGE=”JavaScript”> var nVer = navigator.appVersion; var nAgt = navigator.userAgent; var browserName = ”; var fullVersion = 0; var majorVersion = 0; // In Internet Explorer, the true version is after “MSIE” in userAgent if ((verOffset=nAgt.indexOf(”MSIE”))!=-1) { browserName = “Microsoft Internet Explorer”; fullVersion = parseFloat(nAgt.substring(verOffset+5)); majorVersion = parseInt(”+fullVersion); } // In Opera, the true version is after “Opera” else if ((verOffset=nAgt.indexOf(”Opera”))!=-1) { browserName = “Opera”; fullVersion = parseFloat(nAgt.substring(verOffset+6)); majorVersion = parseInt(”+fullVersion); } // In Firefox, the true version is after “Firefox” else if ((verOffset=nAgt.indexOf(”Firefox”))!=-1) { browserName = “Firefox”; fullVersion = parseFloat(nAgt.substring(verOffset+8)); majorVersion = parseInt(”+fullVersion); } // In most other browsers, “name/version” is at the end of userAgent else if ( (nameOffset=nAgt.lastIndexOf(’ ‘)+1) < (verOffset=nAgt.lastIndexOf(’/')) ) { browserName = nAgt.substring(nameOffset,verOffset); fullVersion = parseFloat(nAgt.substring(verOffset+1)); if (!isNaN(fullVersion)) majorVersion = parseInt(”+fullVersion); else {fullVersion = 0; majorVersion = 0;} } // Finally, if no name and/or no version detected from userAgent… if (browserName.toLowerCase() == browserName.toUpperCase() || fullVersion==0 || majorVersion == 0 ) { browserName = navigator.appName; fullVersion = parseFloat(nVer); majorVersion = parseInt(nVer); } document.write(’Browser name = ‘+browserName+’<br>’); document.write(’Full version = ‘+fullVersion+’<br>’); document.write(’Major version = ‘+majorVersion+’<br>’); document.write(’navigator.appName = ‘+navigator.appName+’<br>’); document.write(’navigator.userAgent = ‘+navigator.userAgent+’<br>’); </script> <a href=”http://avancezone.com”>avancezone</a> </html>
Javascript to know browser name and browser version
<html> <body> <script type="text/javascript"> var browser=navigator.appName; var b_version=navigator.appVersion; var version=parseFloat(b_version); var cdname=navigator.appCodeName; document.write("Browser name: "+ browser); document.write("<br />"); document.write("code name: "+ cdname); document.write("<br />"); document.write("Browser version: "+ version); </script> </body> </html>
Find browser size
Find browser size
Here is the Best and simple way to find the users browser size
The screen size and browser size are different…
A perfect web developer has to fit his developed website to the use rs bowser and not his screen resolution
here is the script to find the users screen resolution .
Javascript to find browser size Just copy and paste in .html file
<script type="text/javascript"> function alertSize() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } window.alert( 'Width = ' + myWidth + ' and height = ' + myHeight ); } </script> <p>Test your screen size <a href="javascript:alertSize();"> Java script resolution</a></p>
