Friday, June 27, 2014

HOW TO MAKE CROSS BROWSER COMPATIBLE WEBSITES


Make your sites cross browser compatible adding  the following java-script code  in your pages head tag :

Make 4 style sheet. for google chrome,1 for fire fox,1 for Internet explorer.
style_google_chrome.css , style_firefox.css , style_IE.css , style.css ,1 for default1 .
<script type="text/javascript">
var browser=navigator.userAgent;
if (browser.lastIndexOf("Chrome")>=5)
{
var callbackFunc = function(){
//alert("WELCOME to Chrome");
};

var head = document.getElementsByTagName( "head" )[0];
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");


fileref.setAttribute("href", "style_google_chrome.css");
fileref.onload = callbackFunc();
head.insertBefore( fileref, head.firstChild );
}
else if(browser.lastIndexOf("Firefox")>=5)
{
var callbackFunc = function(){
//alert("WELCOME to Firefox");
};
var head = document.getElementsByTagName( "head" )[0];
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", "style_firefox.css");
fileref.onload = callbackFunc();
head.insertBefore( fileref, head.firstChild );

}
else if(browser.lastIndexOf("NET")>=5)
{
var callbackFunc = function(){
//alert("WELCOME To Internet explorer");
};
var head = document.getElementsByTagName( "head" )[0];
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", "style_IE.css");
fileref.onload = callbackFunc();
head.insertBefore( fileref, head.firstChild );

}
else
{
var callbackFunc = function(){
//alert("WELCOME others");
};
var head = document.getElementsByTagName( "head" )[0];
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", "style.css");
fileref.onload = callbackFunc();
head.insertBefore( fileref, head.firstChild );

}
</script>

Post a Comment

Add Choice