I have 2 js files. Although both do the same thing one does not work on IE 7, as such I have 2 different JS files. I need one to be called if the browser is IE7 and the other to be called in all other situations.
I have the standard Yii declaration at the top of the page.
<?php
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->baseUrl . '/js/jquery-1.4.4.js');
//etc....
?>
I have tried the following in the document.ready function.
var browserIE7 = (navigator.userAgent.indexOf("MSIE 7")>=0) ? true : false;
if(browserIE7){
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->baseUrl . '/js/IEjquery-1.4.4.js');
}else{
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->baseUrl . '/js/jquery-1.4.4.js');
}
However that does not work. I have never needed to do this before and as such am having difficulty figuring out how to do it.
Any help is appreciated.
Thank you.
If you would like for some js hack you can use in your html as follows to include your script for IE only version
Refer http://code.google.com/p/ie7-js/