SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: "bookmark us" script?
-
Apr 16, 2003, 15:43 #1
- Join Date
- Feb 2003
- Location
- Dog Street
- Posts
- 1,819
- Mentioned
- 1 Post(s)
- Tagged
- 1 Thread(s)
"bookmark us" script?
Hey all. Does anyone know any good cross-browser script
that will add the page to the person's bookmarks?
tia,
--ed
-
Apr 16, 2003, 17:35 #2
- Join Date
- Nov 2002
- Location
- tpyge
- Posts
- 1,085
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
<a href="javascript:window.external.AddFavorite('URL','Name')">add to Favorites</a>
-
Apr 16, 2003, 19:23 #3
- Join Date
- Feb 2003
- Location
- Dog Street
- Posts
- 1,819
- Mentioned
- 1 Post(s)
- Tagged
- 1 Thread(s)
Originally Posted by mydster
--ed
-
Apr 17, 2003, 00:43 #4
Yep, it is. Afaik, it's specifically MSIE/Win (i.e. not supported by MSIE/Mac).
Afaik, at present there is no way to offer an 'add link' kind of facility to other browsers.
So, seeing as you're already using javascript , why not use it to offer the advice/facility that is appropriate to the browser?
Code:<head> ... <script type="text/javascript"> function doLink() { if ( (document.all) && (navigator.platform.indexOf('Win') != -1) ) { document.write("<a href='#' onclick='window.external.AddFavorite('URL','Name')'>Add this page to Favorites</a>"); } else { document.write("Press Control+D to bookmark this page (Command+D for Macintosh)"); } } </script> </head> <body> ... <script type="text/javascript">doLink()</script>
Hope that helps.New Plastic Arts: Visual Communication | DesignateOnline
Mate went to NY and all he got me was this lousy signature
-
Apr 17, 2003, 07:11 #5
- Join Date
- Feb 2003
- Location
- Dog Street
- Posts
- 1,819
- Mentioned
- 1 Post(s)
- Tagged
- 1 Thread(s)
I didn't know if there was a cross-browser way to do it or not.
What I've done so far is just use php to only show the link
if they're using IE. But now that I know that it doesn't work on
mac either I should change this code to also check that the OS
is Windows.
PHP Code:<?php
if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
{
?>
<a href="javascript:window.external.AddFavorite('http://www.mysite.com','The title of my site')" class="bottomLeftNav">Bookmark us</a>
<?php
}
?>
PHP Code:<?php
if ( strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && strstr($_SERVER['HTTP_USER_AGENT'], 'Win'))
{
?>
<a href="javascript:window.external.AddFavorite('http://www.mysite.com','The title of my site')" class="bottomLeftNav">Bookmark us</a>
<?php
}
?>
thanks all,
--ed
-
Apr 17, 2003, 07:23 #6
Quick question...
Is there any benefit in using PHP (your example) rather than javascript (my example) given that the facility you are implementing is javascript-based anyway?New Plastic Arts: Visual Communication | DesignateOnline
Mate went to NY and all he got me was this lousy signature
-
Apr 17, 2003, 11:22 #7
- Join Date
- Feb 2003
- Location
- Dog Street
- Posts
- 1,819
- Mentioned
- 1 Post(s)
- Tagged
- 1 Thread(s)
Originally Posted by Bill Posters
I actually came up with my quick peice of php
last night. If I hadn't already done it I woulda just used your javascript code, as I used mydster's code to open the bookmarks window.
The navigation that this link is a part of is an "included" php file, so it was kinda natural for me to do the logic in php. That's kind of the purpose of my having a seperate file for navigation.
And I'm a quite a bit more comfortable with php than I am with javascript so I probably tend to use php when possible.
So I guess it largely comes down to personal preference.
--ed
Bookmarks