PDA

View Full Version : .AddFavorite problems


oracleguy
10-05-2002, 08:41 AM
I have this code in the head of my page:

<script language="JavaScript">

function addfav(favurl, favtitle){
if (document.all)
{
window.external.AddFavorite(favurl,favtitle)

alert (favtitle+" has been added to your favorites.")
}
}

</script>


And I have a hyperlink in my body like:
<a href="javascript:addfav('www.bawls.com','Bawls Guarana')">Add To Favorites</a>

When I click the link i get the error: "unspecified error" on the window.external line. I've just start learning JS a few weeks ago and I'm still learning; whats wrong with this script?

Ökii
10-05-2002, 09:12 AM
What browser are you using to access the page?

external.AddFavorite is IE5+ only, so the if(doc.all) wouldn't fully limit available browsers.

Try

<script type="text/javascript">
<!--
function addfav() {
if (document.recalc) {
window.external.AddFavorite(location.href, document.title);
}
}
-->
</script>

mordred
10-05-2002, 02:06 PM
<a href="javascript:addfav('http://www.bawls.com','Bawls Guarana')">Add To Favorites</a>

This function is picky, you need to specify a complete URL with the protocol at the beginning.

oracleguy
10-05-2002, 06:46 PM
Originally posted by mordred
<a href="javascript:addfav('http://www.bawls.com','Bawls Guarana')">Add To Favorites</a>

This function is picky, you need to specify a complete URL with the protocol at the beginning.

:D Yep thats what the problem is! Thanks for the replies.