Posted by realityloop on November 15, 2010 at 11:47pm
I'm trying to build a webform plugin that requires some additional JS included for IE browsers based on the version, the JS I'll need to output on webforms is as follows:
<!--[if gte IE 7]><script type="text/javascript" src="excanvas-r71.min.js"></script><![endif]-->
<!--[if IE 6]><script type="text/javascript" src="excanvas-r3.min.js"></script><![endif]-->I've been trying to get drupal_add_js to work, I'm still learning jQuery and am not sure that it is the best way to check for browser or having a lot of luck getting it to work.
Here is where I'm at:
drupal_add_js(if($.browser.msie && parseFloat($.browser.version) < 7) { $.getScript($librarypath . '/assets/excanvas-r3.min.js'); });', 'inline');
drupal_add_js(jQuery(document).if($.browser.msie && parseFloat($.browser.version) > 7) { $.getScript($librarypath . '/assets/excanvas-r71.min.js'); });', 'inline');Could someone provide some insight on if I should be using drupal_add_js or drupal_add_header for performance reasons, and assist me with crafting the correct drupal_add_js string if it is the best approach?

Comments
There would be effectively no
There would be effectively no performance difference. I would use drupal_add_header as I find conditional HTML to be clearer than using JS to parse browser makes and models.
--
Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his
Thanks Dave, that worked for
Thanks Dave, that worked for me..
using drupal_set_html_head() in case others come across the thread.
@BrianGilbert_
Help make Drupal Melbourne meetups more awesome:
http://groups.drupal.org/node/204518
The best way to grow your local commununity is by participating in it!
Conditional Styles
Conditional Styles Module
with javascript support
You might could try this: http://drupal.org/node/639288