Native JS implementation to add favorites code
- 2020-03-26 21:39:39
- OfStack
<html>
<head>
<title>JS Add to favorites </title>
</head>
<script>
function addfavorite()
{
if (document.all)
{
window.external.addFavorite('http://www.baidu.com',' favorites ');
}
else if (window.sidebar)
{
window.sidebar.addPanel(' The baidu ', 'http://www.baidu.com', "");
}
}
</script>
<body>
<a href="#" onclick="addfavorite()"> Join the collection! </a>
</body>
</html>