views:

32

answers:

1

I have a details view with a sidebar and I would like to allow the user to add the current details to their favorites. I'm current using the following javascript, but I don't know how to pass the details id to the javascript to generate the link to be added to the users favorites.

My javascript - This doesn't work of course...

<script language="javascript" type="text/javascript">
    function addfav() 
    {
        if (document.all) 
        {
            window.external.AddFavorite("linkToDetailsScreen" , "FavoritesName")
        }
    }
</script>
+2  A: 

Try this:

window.external.AddFavorite(location.href, document.title);

This adds a favorite for the current page/URL and takes the browser's window title for the favorite title. See here for details.

BTW: this solution only works in IE. See here, here or here for solution which also work in other browsers.

M4N
Thanks!!! That did just what I was needing.
Carl Weis
The target users for the application are all required to run IE, but the links will be helpful for other applications. Thanks.
Carl Weis