Favourite button

  • 1
  • Question
  • Updated 8 years ago
  • Answered
Hi guys,

Can someone help me with the code for being able to add a favourite button to my site in order that people can press on the star and have my page saved in their favourites!!
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes

Posted 8 years ago

  • 1
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
HI Craig

To add this to your site requires you to add two sets of HTML code to your page.

Step 1 - drag and drop an HTML widget at the top of your page. Paste in the following code:

<script type="text/javascript">

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (<a href="http://www.dynamicdrive.com">www.dynamicdrive.com</a>)
*
This notice MUST stay intact for legal use
* Visit Dynamic Drive at <a href="http://www.dynamicdrive.com/">http://www.dynamicdrive.com/</a> 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 - Drag and drop your second HTML widget on your page. Paste in the following code:

<a title="Bookmark this site" href="javascript:bookmarksite('Enter your text here',
'http://mysitesURL.com')"><img style="margin: 0px; padding: 0px;" src="resources/bookmark.jpg" alt=" bookmark star" border="0"></a>

You need to change the following info:

* Change 'Enter your text here' to you own wording.
* Change 'http://mysitesURL.com' to the URL of your site.
* Upload your image to your filemanager and change the src="resources/bookmark.jpg" to your own image name.
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes
Cheers Sanja I will give that a try and hopefully it will work out!
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes
Sanja,

It comes up saying "oops there is an error with your posted javascript code, please check your code" the step 1 part listed!!

The picture is showing up fine of the star but no text next to it and nothing happening when you click on the star!!
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
must be a problem with the java if its not working - try and copy it through notepad first before you paste it into yola.
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes
Uk Duke you were spot on, copied it onto notepad and re copied it onto the site and it works perfectly now, thanks for that!!

Also is there another code I can add to have the star for the bookmark either centered or to the right of my page and have the star showing a bit smaller?
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes
is there a way I can add this into this script into the html somewhere so that I can use this button instead of the star I was using but didnt look very good?

form

input value="Add to Favorites" onclick="window.external.AddFavorite(location.href,
document.title);" type="button"

form

and also have this centered? Your help is greatly appreciated.
Photo of lambofgod

lambofgod

  • 875 Posts
  • 35 Reply Likes
<!--
This supports most browsers, and I use it on my site:

<CENTER><FORM>
<INPUT TYPE="button" VALUE="Add to Favorites" onClick='window.external.AddFavorite(location.href, document.title);'>
</CENTER></FORM>

Good luck :D
-->
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes
Thanks for the reply lambof god and that also works but where do I put this into the code to take over from the star being the link to add to favourites as I would like this button to be used instead as Im no good with code lol
Photo of lambofgod

lambofgod

  • 875 Posts
  • 35 Reply Likes
This is the entire "Favorites" button. The code the was originally posted has nothing to do with the one I posted. Put the one I posted in a new HTML widget on your site where you would like it to display.
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes
Yeah I have done and its great but what I need now is the code for it to actually add my website to your favourites once pressed so I now need code for this to work with the favourites button.
Photo of lambofgod

lambofgod

  • 875 Posts
  • 35 Reply Likes
The code itself is the whole deal. When the person presses the button, it will add the site to the users default favorites folder.
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes
Yeah it works fine on Internet explorer but not firefox, I have just done a work around at the moment as firefox aint liking it at all im afraid!
Photo of lambofgod

lambofgod

  • 875 Posts
  • 35 Reply Likes
Hmm give me a minute to find a conversion to have the fox not eat it up ;)
Photo of lambofgod

lambofgod

  • 875 Posts
  • 35 Reply Likes
Ok Firefox doesn't seem to like using javascript favorite buttons. I do have a solution for you but it might be a tad complicated and your need to have Yola Pro. You want me to give it to you?
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Thanks lambofgod for all your help on this :)
Photo of Craig

Craig

  • 449 Posts
  • 11 Reply Likes
Nah its cool lambofgod I have used a workaround on the site which works just fine cheers anyway!!