hello there,
I 'm new to this, but I'll appreciate it if someone could help me with my script I'm writing a javascript that add's site to favortites. It works fine in IE but not in anything else. This is for a clients site who uses Mac and linux. I want it to work in all browsers (IE,FireFox,Safari,google Chrome, and Opera).
thanks for your time and please help

and this is the code

<html>
<body>


<script language="JavaScript" type="Text/Javascript">
<!-- 

var urlAddress = "http://www.maktoob.com"; 
var pageName = "index.php";

function addToFavorites() 
	{ 
	if (window.external) 
	{
	window.external.AddFavorite(urlAddress,pageName) 
	} 
	else 
	{ 
	alert("Sorry! Your browser doesn't support this function."); 
	}
	} 
	
	
// -->
</script>

<script>
	/* Modified to support Opera */
function bookmarksite(title,url)
	{

	if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
	else 
	if(window.opera && window.print)
	{ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
	} 
	else
	if(document.all)// ie
	window.external.AddFavorite(url, title);
	}
 
	
// -->
</script>

<a href="javascript:addToFavorites()"><font color="#0000FF" 
face="Arial">Bookmark Page !</font></a> 
 <br/><br/><br/>
 
 <a href="javascript:bookmarksite('minamerica', 'http://www.maktoob.com')">Bookmark this site!</a>
  
</body>
</html>
<FORM>
<INPUT TYPE="button" VALUE="Add to Favorites" onClick='window.external.AddFavorite(location.href, document.title);'>
</FORM>
<html>
<head runat ="server" >
<title ></title>
</head>

<script type="text/javascript">
        function Add_Bookmark_Favorite(url,title) 
        {
         if (window.sidebar) 
         { // Mozilla Firefox Bookmark
             //Make sure "Load this bookmark in the sidebar is deselected
          window.sidebar.addPanel(title, url,"");
          return false;
         } 
         else if( window.external ) 
         { // IE Favorites
          window.external.AddFavorite( url, title); 
          return false;
         }
         else if(window.opera && window.print) 
         { // Opera Bookmark
                return !addToFav(url,title)
            }
            else
            {
             window.sidebar.addPanel(title, url,"");
          return false;
            alert('Press CTRL+D to bookmark the page'); 
            }
        }
    </script>

<body>
<form runat ="server" >
<a href="" title="" rel="sidebar" onclick="return Add_Bookmark_Favorite(location.href, document.title);">Bookmark </a>
</form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.