Welcome, Guest. Please Login or Register
Welcome To Ask The Trades!
May 5th, 2024, 11:25pm
Quote: If I agreed with you, we'd both be wrong


Page Index Toggle Pages: 1
Send Topic Print
Favorites (Read 3819 times)
cumbriahandyman
GDPR opt-out









Favorites
Jun 10th, 2012, 6:09pm
 
I am looking for an html code for my website so that people can click it to put my site into their favorites folder.

I have one already but when clicked on it opens the favorites folder but had gadget in the name box. I want it to say Handyman Cumbria.

Cheers
Back to top
 
 
IP Logged
 
Lectrician
Administrator
Trade Member
Author
*****
Offline

Ask The Trades
Posts: 8814


Total Thanks: 109
For This Post: 0


Braunton, North Devon, United Kingdom
Braunton, North Devon
United Kingdom

Gender: male

Trade: Electrician



Re: Favorites
Reply #1 - Jun 10th, 2012, 6:25pm
 
These buttons are a little out of date these days as adding a favourite to your browser is quick and easy.

Drag the page to the top bar, use the menu, or simply press CTRL & D.

To add a button, you need to use some javascript.

Because there are so many browsers these days, and so many people use ones other than IE, this becomes tricky.

Let me take a look at some code it a bit, however, the name for the favorite is usually taken from the <title></title> tag you have for your website.  What was the title of your website (in the top browser bar) where you button or link was?
Back to top
« Last Edit: Jun 10th, 2012, 7:00pm by Lectrician »  

Need to post a picture? Click HERE for info!
Thank User For This Post WWW View members image gallery  
IP Logged
 
cumbriahandyman
Re: Favorites
Reply #2 - Jun 10th, 2012, 6:36pm
 
Its on my home page is that what you meant?
Back to top
 
Thank User For This Post  
IP Logged
 
Lectrician
Administrator
Trade Member
Author
*****
Offline

Ask The Trades
Posts: 8814


Total Thanks: 109
For This Post: 0


Braunton, North Devon, United Kingdom
Braunton, North Devon
United Kingdom

Gender: male

Trade: Electrician



Re: Favorites
Reply #3 - Jun 10th, 2012, 6:53pm
 
Copy and paste the below into a text file and save it as fav.html or something - then give it a try.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test Add To Favorites</title>
<script language="JavaScript" type="text/javascript">
function addFav(title, url) {
 if (window.sidebar){ // For Firefox
   window.sidebar.addPanel(title, url, "");
   return false;
 }
 else if( window.external ){ // For Internet Explorer & Safari
   window.external.AddFavorite(url, title);
   return false;
 }
 else if(window.opera && window.print){ // For Opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
    return false;
 }
}
</script>
</head>
<body>
<input type="button" value="Bookmark Us!" onclick="addFav('My Title Here', 'http://myURLlink.com');"><p>
Or - do you want a text link?<p>
<a href="javascript:void(0);" onclick="addFav('My Title Here', 'http://myURLlink.com');">Bookmark Us!</a><p>
Incidently - Google Chrome does not allow javasctipt to add a bookmark (it's version of a favorite).
</body>
</html>
Back to top
 

Need to post a picture? Click HERE for info!
Thank User For This Post WWW View members image gallery  
IP Logged
 
Lectrician
Administrator
Trade Member
Author
*****
Offline

Ask The Trades
Posts: 8814


Total Thanks: 109
For This Post: 0


Braunton, North Devon, United Kingdom
Braunton, North Devon
United Kingdom

Gender: male

Trade: Electrician



Re: Favorites
Reply #4 - Jun 10th, 2012, 6:57pm
 
Quote:
Its on my home page is that what you meant?


Looking at your code, it is from a creator type site, and is using the javascript variable "document.title" which should pull your websites title in as the favorite name (could also try this.title).  The title you have is simply "Home" though.  You should have the website set as your title.

The code I have done above doesn't use these variables and you can set them as you wish.

You should have in your head of the webpage <title>My Website Name - Home</title> rather than just <title>Home</title>

You can also put after your "If this button doesn't work, add us manually" text, "press CTRL & D!"
Back to top
« Last Edit: Jun 10th, 2012, 7:03pm by Lectrician »  

Need to post a picture? Click HERE for info!
Thank User For This Post WWW View members image gallery  
IP Logged
 
cumbriahandyman
Re: Favorites
Reply #5 - Jun 10th, 2012, 7:20pm
 
Cheers for that the code would not work on my site but I have added the ctrl + D. I think I will leave it at that.

I do appreciate you putting in the time to help.

John
Back to top
 
Thank User For This Post  
IP Logged
 
Lectrician
Administrator
Trade Member
Author
*****
Offline

Ask The Trades
Posts: 8814


Total Thanks: 109
For This Post: 0


Braunton, North Devon, United Kingdom
Braunton, North Devon
United Kingdom

Gender: male

Trade: Electrician



Re: Favorites
Reply #6 - Jun 10th, 2012, 7:23pm
 
You would need to put everything in the <script> tags (with the script tags still) inside your <head> tag - usually after the <title> tag.

Then the HTML button where ever you want.

Did you copy and paste the code above into a clean page and tried that?

Send me the file if you want.
Back to top
 

Need to post a picture? Click HERE for info!
Thank User For This Post WWW View members image gallery  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print