943,910 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Apr 3rd, 2005
0

"add this site to your bookmarks" in firefox

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
MrScruff is offline Offline
89 posts
since Nov 2004
Apr 4th, 2005
0

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

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>
Reputation Points: 54
Solved Threads: 20
Master Poster
DaveSW is offline Offline
765 posts
since Jul 2004
Apr 4th, 2005
0

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

Thats a nice little script cheers! I'll try it out soon.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
MrScruff is offline Offline
89 posts
since Nov 2004
May 26th, 2005
0

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

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...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Viper is offline Offline
1 posts
since May 2005
Jul 28th, 2005
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pablo99 is offline Offline
2 posts
since Jul 2005
Jul 30th, 2005
0

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

Hi Pablo
That doesn't happen for me...
What browser/version are you using?
Dave
Reputation Points: 54
Solved Threads: 20
Master Poster
DaveSW is offline Offline
765 posts
since Jul 2004
Aug 1st, 2005
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pablo99 is offline Offline
2 posts
since Jul 2005
Jan 21st, 2007
0

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

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!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
heepofajeep is offline Offline
4 posts
since Jan 2007
Jan 21st, 2007
0

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

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.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jan 22nd, 2007
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
heepofajeep is offline Offline
4 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: What do you use to parse the url?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: AJAX not working on firefox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC