[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to create a bookmark link with php?

Posted on 2007-10-10
2
Medium Priority
?
194 Views
Last Modified: 2008-02-17
I am wanting to put a 'Bookmark this page" link on my website, preferably with PHP. The link would be on multiple pages and when pressed bookmark the specific page the user is on at the time. Any ideas on the best way to do this?
0
Comment
Question by:guy4graphics
2 Comments
 
LVL 51

Expert Comment

by:Steve Bink
ID: 20050439
First, PHP will not have anything to do with this.  PHP is a server-side language.  By the time the users gets the information, PHP should already have finished processing.

You'll need to a put a javascript link in your HTML.  IIRC, that only works for IE... Firefox requires that the user press a local key combination (ctrl-d) to generate a bookmark in the local store.

Searching google for 'javascript add bookmark' yields a few examples supposed to work across browsers.  You'll have to experiment with it a bit, I think.
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 2000 total points
ID: 20052384
Agree with routinet, it is only client-side not server-side.

This is an example that is reported to work on firefox, mozilla and safari, but I am not sure since I have not tried it:

#####
function addBookmark(title, url){
        if(window.sidebar){ // Firefox
          window.sidebar.addPanel(title, url,'');
        }else if(window.opera){ //Opera
          var a = document.createElement("A");
          a.rel = "sidebar";
          a.target = "_search";
          a.title = title;
          a.href = url;
          a.click();
        } else if(document.all){ //IE
          window.external.AddFavorite(url, title);
        }
      }
########

Also another example which is bound to work, but only truely works in IE, and for other browsers it would output the hotkey combo for bookmarking the site:

#########

<script type='text/javascript'>
<!--
var IEstring = "<a href='javascript:window.external.addFavorite"
IEstring += "(location.href,document.title);' title='Add to Favorites'>Favorites<\/a>" ;
var NSstring = "Click [Ctrl + D] ";
var OPstring = "Click [Ctrl + T]";
var OTHstring = "bookmark this page!"
var whichString = OTHstring ;
var agt = navigator.userAgent.toLowerCase();
var app = navigator.appName.toLowerCase();
var ieAgent = agt.indexOf('msie');
var nsAgent = app.indexOf('netscape');
var opAgent = app.indexOf('opera');
if (ieAgent!= -1) { whichString = IEstring; } else if (nsAgent!= -1){ whichString = NSstring; } else if (opAgent!= -1){whichString = OPstring; }
document.write(whichString)
-->
</SCRIPT>

########

Though the second script is not idea, it is probably the most reliable.

Please let us know how you go.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question