PDA

View Full Version : Resolved Browser Specific Javascript Loading



andy@tcws
06-04-2009, 09:17 AM
How do I load a specific js file according to the browser in this instance for ie8?

Is there some kind of conditional I can do, much like browser specific CSS loading, that would appear in the head of the html?

Thanks in advance.

Nile
06-04-2009, 11:54 AM
Like this?:


<!--[if IE 8]>
<script type="text/javascript" src="script8.js">
//Blah
</script>
<![endif]-->

andy@tcws
06-04-2009, 12:06 PM
That's great thanks Nile.

So if I need IE8 to load blah1.js and all other browsers to load blah2.js would it need some kind of if/else statement? I'm not really sure of the syntax though.

Cheers. :)

molendijk
06-04-2009, 05:49 PM
You only have to do this:

<!--[if IE 8]>
Script for Internet Explorer 8
<![endif]-->

<!--[if lt IE 8]><!-->
Script for EITHER Internet Explorer lower_then_8 OR non-IE
<!--<![endif]-->

===
Arie Molendijk.

Nile
06-04-2009, 09:32 PM
No actually... You only have to do this:


<!--[if IE 8]>
<script type="text/javascript" src="blah1.js">
//Blah
</script>
<![endif]-->
<!--[if lt IE 8]><!-->
<script type="text/javascript" src="blah2.js">
//Blah
</script>
<!--<![endif]-->

molendijk
06-04-2009, 09:36 PM
<!--[if IE 8]>
<script type="text/javascript" src="blah1.js">
//Blah
</script>
<![endif]-->
<!--[if lt IE 8]><!-->
<script type="text/javascript" src="blah2.js">
//Blah
</script>
<!--<![endif]-->

... meaning that Nile and I agree.
===
Arie.

andy@tcws
06-05-2009, 09:13 AM
Thanks guys, that's awesome. Works like a charm :)

Removed the reflection from MooFlow, as it was borked in IE8 and seems to be an outstanding unresolved issue.

Example (http://www.creativeadvertising4u.co.uk/directory-magazine-advertising.html)

Nile
06-05-2009, 11:56 AM
... meaning that Nile and I agree.
===
Arie.

Yes, I was saying no the the OP.

Great glad to help!