Bookmark this page

Posted on 2005-04-16
Last Modified: 2013-12-24

I am looking for a script that would allow users to bookmark a page. The problem is that the link to bookmark the page is in an include file so I would want it to automatically determine the current page the user is on. I cannot prepopulate the link as there are many pages on my site and the majority of them are static. Some are dynamic however. Can someone help me with this?

Question by:cmaorg
    LVL 12

    Expert Comment

    to do this you would want a bit of javascript - this is easy in IE, but I have never come across a script that works on all browsers.

    Try this:

    This bit should go in the header or footer file of you site.

    <Script Language = "JavaScript" Type="Text/JavaScript">
    <!--  Hide script from older browsers
     var urlAddress = "";
     var pageName = "Title of the page";

     function addToFavorites()
      if (window.external)
       alert("Sorry! Your browser doesn't support this function.");
    // -->

    Place this wherever you want the link to appear:

    Click <a href="javascript:addToFavorites()">here</a> to bookmark this story!

    Instead of putting in a static domain here I used to give me the exact page I am on.  Hopefully you use dynamic titles, so you can replace
    LVL 5

    Accepted Solution

    I think what you want is:<cfif len(cgi.query_string) NEQ 0>?#cgi.query_string#</cfif>

    query_string just contains the dynamic data, not the actual pathname and filename.
    LVL 5

    Expert Comment

    you might want to try the following:

    <CFSET CurrentURL = 'http://' & CGI.SERVER_NAME & CGI.SCRIPT_NAME>

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Nginx CDN 12 101
    IIS Load balancing 5 51
    IIS 8.5 (Windows 2012 R2) Problems Browsing Virtual Directories 15 77
    Running Guacamole on port 80 5 72
    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 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

    15 Experts available now in Live!

    Get 1:1 Help Now