"add this site to your bookmarks" in firefox

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2004
Posts: 89
Reputation: MrScruff is an unknown quantity at this point 
Solved Threads: 0
MrScruff's Avatar
MrScruff MrScruff is offline Offline
Junior Poster in Training

"add this site to your bookmarks" in firefox

 
0
  #1
Apr 3rd, 2005
Is it possible to have a link so users can add my site to their bookmarks via a link? I have found out how to do it using IE but it doesn't work with Firefox.

Cheers for anyhelp.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 764
Reputation: DaveSW is on a distinguished road 
Solved Threads: 17
DaveSW's Avatar
DaveSW DaveSW is offline Offline
Master Poster

Re: "add this site to your bookmarks" in firefox

 
0
  #2
Apr 4th, 2005
This function appears to work in both:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. function addBookmark(title,url) {
  3. if (window.sidebar) {
  4. window.sidebar.addPanel(title, url,"");
  5. } else if( document.all ) {
  6. window.external.AddFavorite( url, title);
  7. } else if( window.opera && window.print ) {
  8. return true;
  9. }
  10. }
  11. </script>

I'm using that with this link:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <a href="#"
  2. onmousedown="addBookmark('Williamsons Oldham','http://williamsons-oldham.co.uk/')"><img src="graphics/bookmark.gif" alt="bookmark this page" border=0 /> Bookmark this page</a>
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 89
Reputation: MrScruff is an unknown quantity at this point 
Solved Threads: 0
MrScruff's Avatar
MrScruff MrScruff is offline Offline
Junior Poster in Training

Re: "add this site to your bookmarks" in firefox

 
0
  #3
Apr 4th, 2005
Thats a nice little script cheers! I'll try it out soon.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 1
Reputation: Viper is an unknown quantity at this point 
Solved Threads: 0
Viper's Avatar
Viper Viper is offline Offline
Newbie Poster

Re: "add this site to your bookmarks" in firefox

 
0
  #4
May 26th, 2005
DaveSW

I love the script. Thanks!

Question: How (if at all), can the "href" command be modified so that - instead of having the title and url "hardcoded" - the command could instead take the "document.title" and the "document.location" (same as I have done for my mailto scripts)...

[document.write(" <a href=\"mailto:?subject=" + escape("Voici un lien à une recette intéressante...") + "& body=" + escape(document.title) + "%0A"+ document.location + "\">") ;]

Thanks...
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 2
Reputation: pablo99 is an unknown quantity at this point 
Solved Threads: 0
pablo99 pablo99 is offline Offline
Newbie Poster

Re: "add this site to your bookmarks" in firefox

 
0
  #5
Jul 28th, 2005
hey guys. firstly, thanks for your script! ive been searching and google led me here

the only problem i have is that the script defaults the bookmark's property so that it opens in the sidebar. would you be able to tell me how to stop this?

thanks!

pablo
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 764
Reputation: DaveSW is on a distinguished road 
Solved Threads: 17
DaveSW's Avatar
DaveSW DaveSW is offline Offline
Master Poster

Re: "add this site to your bookmarks" in firefox

 
0
  #6
Jul 30th, 2005
Hi Pablo
That doesn't happen for me...
What browser/version are you using?
Dave
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 2
Reputation: pablo99 is an unknown quantity at this point 
Solved Threads: 0
pablo99 pablo99 is offline Offline
Newbie Poster

Re: "add this site to your bookmarks" in firefox

 
0
  #7
Aug 1st, 2005
Hi Dave,

I'm using Firefox 1.0.6 and as I say the bookmark opens in the sidebar. I see there is an option in the bookmark properties to turn it off, but for some reason it defaults to on when the bookmark is created.

Pablo
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 4
Reputation: heepofajeep is an unknown quantity at this point 
Solved Threads: 0
heepofajeep heepofajeep is offline Offline
Newbie Poster

Re: "add this site to your bookmarks" in firefox

 
0
  #8
Jan 21st, 2007
Cool script-- thank you very much!

My question is, for my application, I would like to be able to have the bookmark refer to a dynamically changed page...

The part of your example that used:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <a href="#"
  2. onmousedown="addBookmark('Williamsons Oldham','http://williamsons-oldham.co.uk/')"><img src="graphics/bookmark.gif" alt="bookmark this page" border=0 /> Bookmark this page</a>
is the part I would like to change. Ideally, I would like to use ...addBookmark('mysite',<? echo 'http://mysite'; ?>)... Of course, this does not work, so is there a way to make something similar work?

Where I used the php echo, I just used echo to simulate a very simple php command.



I am sure this is more-or-less a fundamental javascript/php interaction question, but unfortunately I am very new to javascript.

Thanks!!!
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: "add this site to your bookmarks" in firefox

 
0
  #9
Jan 21st, 2007
To 'interact' between javascript and PHP, you have to either use PHP to create javascript code, or use XMLHTTP requests in javascript to access PHP scripts and then handle the output if neccessary.

You cannot write javscript code that directly invokes PHP code. javscript is processed on a client's computer; PHP is processed at the server as a page is requested. Javscript only ever runs after the PHP processor has done its work (and removed all PHP blocks from its output files)

That doesn't mean that you cant create javascript code based on or affected by a PHP process; it just means that the javascript in a PHP file will do what the PHP code tells it to do.

So, by the time javascript runs; this PHP code:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. addBookmark('mysite',<? echo 'http://mysite'; ?>)

will always end up as this javscript code:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. addBookmark('mysite',http://mysite);

And that code wont work because of quoting.

But this PHP code:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. addBookmark('mysite','<? echo 'http://mysite'; ?>');

Generates this code:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. addBookmark('mysite','http://mysite');

Which should work.
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 4
Reputation: heepofajeep is an unknown quantity at this point 
Solved Threads: 0
heepofajeep heepofajeep is offline Offline
Newbie Poster

Re: "add this site to your bookmarks" in firefox

 
0
  #10
Jan 22nd, 2007
Cool, thank you much! That did the trick.

So, just one other item ... Do you guys know if there is any way to alter the description of the bookmark? This is more of a firefox thing, but it would still be cool, although not necessary.

Thanks again
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC