Reputation: 70
I need to include some JavaScript for a BMI calculator in a WordPress blog.
The BMI Calculator is here.
However, WordPress strips out the code when the page is published.
Short of using some form of iframe
to show the script, is there any other way?
Thanks, Christine.
Upvotes: 0
Views: 220
Reputation: 18013
I have inserted a jQuery script to an existing site before using javascript. Here is the code I used, you may be able to adapt it to add you library.
<script>
//Insert JQuery Javascript Library
if(!window.MyLibrary){window.MyLibrary={};s=document.createElement('script');s.type= 'text/javascript';s.src=window.location.href.replace(/((custompages)|(eware.dll)).*/i,'')+'custompages/jquery-1.4.4.min.js';document.getElementsByTagName('head')[0].appendChild(s);}
</script>
You may need to reference a library hosted on the internet rather than on wordpress
Upvotes: 0
Reputation: 58
I haven't tried embedding that particular script you mention in a page but every time I need to include any other javascript in my wordpress site I use the plugin:
http://www.matteoionescu.com/wordpress/embed-html/
This allows you to take advantage of the custom fields to insert code directly into the page.
Upvotes: 4