tags:

views:

33

answers:

2

Hello,

I have page for which I want to load different .tpl for different browsers.

I found this code to include external files using Jquery.

$.getScript("1.js",function() {
            //this script is loaded
});

I want to make above code conditional based on browsers for Example

if($.browser.msie)

$.getScript("1.tpl",function() {  
//this includes external file - 1.tpl

}else{

$.getScript("2.tpl",function() {   
//for other browser includes external file - 2.tpl

I am not javascript coder ... Can anyboby make this work ?

Thanks,

  • Mandar
+2  A: 

I think you are looking for load method.

Sarfraz
@sAc: Thanks for reply. but .load seems tobe limited for #div. I need to load complete page which has multiple div.
MANnDAaR
@manndaar: You can include the files at specified position/element by specifying the id of that element and page name to be loaded (as can be seen in examples on documentation) or as an alternative if you find it comfortable with it, you can use the $.ajax handler to include the whole file. more info: http://api.jquery.com/jQuery.ajax/ but essentially it is same thing.
Sarfraz
A: 

Looks like you had some syntax errors with your curly brackets, etc.

Try this:

if($.browser.msie)
{
    $.getScript("1.tpl",function() {  
        //this includes external file - 1.tpl
    })
}
else
{
    $.getScript("2.tpl",function() {   
    //for other browser includes external file - 2.tpl
    })
}

I should add that I have no idea what a .tpl is so all I did was corrected the syntax of your javascript. You may need to change the actual funciton calls as metnioend by others here.

Chris