« Why my 3D photos album don't display some of my images ? | HomePage | Nice comments form for your blog »
2005.05.25
Javascript in your blog
As Lionel asked me for inserting javascript code in a blogSpirit blog, here is an exemple with the "add to bookmark feature".
Technical notes :
BlogSpirit blogs use Smarty technology which is a php template parser.
Smarty tags are like {tag}{/tag}, that's why javascript code may be misunderstood if they contain ths type of caracter. The solution is to use the following Smarty tags : {literal]{/literal} between your javascript code (works also for CSS code)
"Add to bookmarks"
I really disagree with this type of feature which work only with some versions of IE (not working on Gecko type browser : Firefox, Safari, Netscape...)
Create a new custom box and insert the following code :
<script type="text/javascript">
{literal}
function add_favoris() {
var site_name = "Technoblog !";
var site_url = "http://technoblogs.blogspirit.com";
if ((navigator.appName.indexOf("Microsoft",0)>=0) && (parseInt(navigator.appVersion)>=4)) {
window.external.AddFavorite(site_url,site_name );
} else {
alert("This d*feature works only with Internet Explorer 4+, perfom a Ctrl+D to add "+var site_name+" to your bookmarks.");
}
}
{/literal}
</script>
<a href="javascript:add_favoris();">Add to my bookmarks</a>
NB : this script only works with IE 4 or more (your IE should be OK), if you want to use this script, don't forget to replace 'site-name' and 'site_url' by your blog title and url.
NB2 : {literal}{/literal} tags are used to avoid the SYNTAX ERROR message when updating your template or custom box. If you still have this message or your blog don't display well, try to :
- check if your tag is closed with : {/literal}
- check if the 'literal' tags are just around some javascript or css code not html code
09:35 Posted in Tips | Permalink | Comments (2) | Trackbacks (0) | Email this | Tags: Blogosphere
Trackbacks
The URL to Trackback this post is: http://technoblogs.blogspirit.com/trackback/142149
Comments
I came across your great blog when i did a search for Blospririt and Inetner Expolorer. Its seems taht while my blog looks fine in Mozilla, my posts are all in the right sidebar when displayed using IE. This just started a couple of days ago--do you have any idea what's up?
Thank you!
Posted by: kaitlyn | 2005.06.22
Thanks for the tip on Javascript with Blogspirit. On my blog, I'm trying to setup a javascript code that, when I click on a link, the picture corresponding to the link pops up. I have it set up as it should be to work, but whenever I try it out on my blog I just get an error message! Do you have any ideas?
Posted by: Sarah | 2006.04.17

