dtzk85937 2011-04-25 08:29
浏览 73
已采纳

当用户来自书签时获取以前的URL?

I want to make a bookmark, with a pseudo share-it functionality. It would redirect the user to a website and on there I would need the URL the user was when he clicked on my bookmark.

I've read many questions regarding the subject but it seems that is difficult if not impossible to get the previous URL if the user wasn't referred by other page.

Is it possible to do it?

Thanks

  • 写回答

1条回答 默认 最新

  • duanleixun2439 2011-04-25 08:45
    关注

    Make a bookmark like this:

    javascript:location='http://www.example.com/?ref='+escape(location.href);
    

    A common way to make this work for the user is making a link as the following:

    <a href="javascript:location='http://www.example.com/?ref='+escape(location.href);"
     onclick="alert('Drag this link to your boomarks toolbar');return false;">
      Bookmark text
    </a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?