I have a HTML page.
In that, according to the browser, I need to include a separate JavaScript file.
How is it possible?
<script type="text/javascript">
if(navigator.appName == 'Microsoft Internet Explorer')
{
//here i need to include one.js
}
else
{
//here i need to include two.js
}
</script>
Of course, you could also split the ternary operator above to your liking...
Simple and easy. 1 line per JS file.
If you're using jQuery, you could use getScript()
http://api.jquery.com/jQuery.getScript/
Using conditional comments you do some HTML only in IE.
you can use conditional comments as outlined on http://jagregory.com/writings/using-ies-conditional-comments-for-targeted-javascript/
for example if you wanted to target IE versions 7 and below you could:
Here is one way, possibly not the best.