How to create a bookmark link with php?

Posted on 2007-10-10
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?
Question by:guy4graphics
    LVL 50

    Expert Comment

    by:Steve Bink
    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.
    LVL 21

    Accepted Solution

    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";
     = "_search";
              a.title = title;
              a.href = url;
            } 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; }


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

    Please let us know how you go.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now