Monday, March 26, 2007

Add to Favorite in Firefox and IE

      I was looking for the javascript to add the link in favorite. I have tried window.external.AddFavorite(location.href, document.title) which is working only in IE. I need to do that for firefox also. After spending few mnutes on google, I found the code working in both.

<script type="text/javascript">
function bookmarksite()
{
         if (document.all)
        {
             // For IE
             window.external.AddFavorite(location.href, document.title);
         }
        else if (window.sidebar)
       {
             // For Firefox
             window.sidebar.addPanel(document.title, location.href, "");
        }
}
< /script>

< a href="javascript:bookmarksite();"> Add to favorites< /a>

Happy Programming !!

2 comments:

ukhti said...

Thankyou, worked great

sanjeev said...

getting error permission denied on IE .