Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a link to favorites -- link is not current page url

Status
Not open for further replies.
If you use frames on your main page, you can keep the same url in address bar. If that's not an option, you can show them a link to click in IE:
Code:
<a href="javascript:window.external.AddFavorite('[URL unfurl="true"]http://mypage.com','My[/URL] Page')">Bookmark</a>

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
As I described above, I want user use browser menue to add favorites instead of adding a link to bookmark. We don't have too much on tool bar to add this link. The key question here is how to bookmark the site without including those attached strings Such as "?name=aaa&site=.."
Thanks!
 
just modify adam's code:
Type something in the text box and submit the page, you'll see the parameters added to the url, then click the bookmark button to bookmark it w/o the parameters
Code:
<script language=javascript>

function addBookmark() {
   var thisPage = String(document.location);
   thisPage = thisPage.split("?");
   alert(thisPage[0]);
   window.external.AddFavorite(thisPage[0],'My Page')
}

</script>
<form name=blahForm>
<a href="javascript:addBookmark()">Bookmark</a><br>
<input type=text name=blahText><br>
<input type=submit value='submit me'>
</form>

-kaht

banghead.gif
 
royyan,
When the user adds a bookmark from the file menu, it'll record whatever is in the address bar. The only way to control it that I can think of is by never changing the url in the address bar as your user navigates your site. As I mentioned above, you can do this by using frames on your home page and having the user navigate within the frameset. The url in the address bar will remain unchanged.

Another option may be to keep the parameters from showing up in your address bar by submitting your forms via the "POST" method.

Other than these two options and the code I posted earlier, there's not much else you can do. If you were able to change the url in the address bar without changing the page, it would be a security issue.

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Hi adam and Kaht,
Thank you both for the help. I think Adam's "frame" suggestion is good in my case. Actually I do use lot's of framesets in my web pages. Now, I need to think how to keep the url I want in the address bar. Post method may not work in my case because it generates links in leading page dynamically.
I will let you guys updated once I figure out a best way in my case.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top