Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Add us to your Favorites
Topic Started: Aug 3 2005, 06:50 PM (1,624 Views)
IF Skinner
Member
 *  
It's pretty much self explanitory.

Javascript:

Quote:
 
<script language="javascript" type="text/javascript">
<!--

var myurl;
var mytitle;

myurl="Your Site URL";
mytitle="Your Site Title";

function favorite(){
  if(navigator.appName!="Netscape"){
  window.external.AddFavorite(myurl,mytitle);
  } else{
  alert("The Add To Favorites function will only work in Internet Explorer.");
  }
}
// -->
</script>


Header & Body

Quote:
 
<a href="javascript:favorite()">Add To Favorites!</a>
Offline Profile Quote Post Goto Top
 
Bluefire16
Member
 *   *  
I can't get it to work. :/
Offline Profile Quote Post Goto Top
 
HolySavior
Member Avatar
if( holy + alcohol){ happycoding()}
 *   *   *   *   *   *   *  
add to favorites

add to favorites link
Offline Profile Quote Post Goto Top
 
fdol
Member
 *   *  
Is there one that will work with all browsers?
Offline Profile Quote Post Goto Top
 
ExTaCy1337
Member
 *  
Yes someone post a js script for all broswers... Especially for Firefox :/
Offline Profile Quote Post Goto Top
 
Codes Rock
Member Avatar
<?php echo 'Codes Rock rocks!'; ?>
 *   *   *  
ExTaCy1337
Jul 22 2008, 05:57 PM
Yes someone post a js script for all broswers... Especially for Firefox :/
This is a cross browser (Firefox 1.x+, IE4+ and Opera7+) script for allowing the user to easily bookmark your site, by clicking on a link on the page.

Step 1: Add the below code to the <head> section of your page:

Code:
 
<script type="text/javascript">

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* 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>


Step 2: Create either an image or text link that will be used as the Bookmark Site link. For the href attribute, use the following code:

Code:
 
javascript:bookmarksite('title_of_site', 'url_of_site')


Here's an example:

Code:
 
<a href="javascript:bookmarksite('Image Uploader Example', 'http://z4.invisionfree.com/HMIS_Example2/')">Bookmark this site!</a>


Remember, if your site's title contains apostrophes, they need to be backslashed when entered:

Code:
 
<a href="javascript:bookmarksite('Mike\'s Place', 'http://www.google.com')">Bookmark this site!</a>
Offline Profile Quote Post Goto Top
 
fdol
Member
 *   *  
I can't get it to work
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code Snippets · Next Topic »
Add Reply