admin管理员组文章数量:1290976
I am attempting to create a bookmarklet that will change the URL of the page I am currently on, and load a new page with the URL string changed. I have reviewed a number of other threads on bookmarklets, but I haven't found a solution that works for me.
I would like to be able to change a URL that looks like this:
.html?referral=Google&visit=1
to:
.html?dog=Fido&cat=Mittens
The three goals:
1) Delete anything in the existing URL after the ? mark.
2) Append "dog=Charlie&cat=Mittens" after the question mark.
3) Immediately load this new page, with the new URL
It seems simple enough, but I have not been able to figure out how to do this. Any help would be greatly appreciated!
I am attempting to create a bookmarklet that will change the URL of the page I am currently on, and load a new page with the URL string changed. I have reviewed a number of other threads on bookmarklets, but I haven't found a solution that works for me.
I would like to be able to change a URL that looks like this:
http://mywebsite./directory/page.html?referral=Google&visit=1
to:
http://mywebsite./directory/page.html?dog=Fido&cat=Mittens
The three goals:
1) Delete anything in the existing URL after the ? mark.
2) Append "dog=Charlie&cat=Mittens" after the question mark.
3) Immediately load this new page, with the new URL
It seems simple enough, but I have not been able to figure out how to do this. Any help would be greatly appreciated!
Share Improve this question asked May 30, 2011 at 19:14 JohnJohn 731 silver badge3 bronze badges1 Answer
Reset to default 10Try this:
javascript: window.location = window.location.protocol + '//' + window.location.hostname + window.location.pathname + '?dog=Charlie&cat=Mittens';
本文标签: javascriptCreating Bookmarklet Append current URL with specific stringStack Overflow
版权声明:本文标题:javascript - Creating Bookmarklet: Append current URL with specific string - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741515555a2382864.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论