| | |
"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
![]() |
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.
Cheers for anyhelp.
This function appears to work in both:
I'm using that with this link:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type="text/javascript"> function addBookmark(title,url) { if (window.sidebar) { window.sidebar.addPanel(title, url,""); } else if( document.all ) { window.external.AddFavorite( url, title); } else if( window.opera && window.print ) { return true; } } </script>
I'm using that with this link:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<a href="#" onmousedown="addBookmark('Williamsons Oldham','http://williamsons-oldham.co.uk/')"><img src="graphics/bookmark.gif" alt="bookmark this page" border=0 /> Bookmark this page</a>
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...
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...
Hi Pablo
That doesn't happen for me...
What browser/version are you using?
Dave
That doesn't happen for me...
What browser/version are you using?
Dave
•
•
Join Date: Jan 2007
Posts: 4
Reputation:
Solved Threads: 0
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: is the part I would like to change. Ideally, I would like to use
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!!!
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)
<a href="#" onmousedown="addBookmark('Williamsons Oldham','http://williamsons-oldham.co.uk/')"><img src="graphics/bookmark.gif" alt="bookmark this page" border=0 /> Bookmark this page</a>
...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!!!
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:
will always end up as this javscript code:
And that code wont work because of quoting.
But this PHP code:
Generates this code:
Which should work.
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)
addBookmark('mysite',<? echo 'http://mysite'; ?>)
will always end up as this javscript code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
addBookmark('mysite',http://mysite);
And that code wont work because of quoting.
But this PHP code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
addBookmark('mysite','<? echo 'http://mysite'; ?>');
Generates this code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
addBookmark('mysite','http://mysite');
Which should work.
Plato forgot the nullahedron..
![]() |
Similar Threads
- How to add games to my site? (ASP.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: What do you use to parse the url?
- Next Thread: AJAX not working on firefox
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child close column createrange() css cursor date debugger dependent disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math media microsoft mimic object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post problem programming progressbar regex runtime scriptlets scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n







... 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.