[英]Javascript bookmarklet to remove a portion of url
我希望通过单击将删除flickr url末尾的书签的脚本来运行脚本的任何帮助。
我目前有以下代码
javascript:(function(){location.href=location.href.replace('/in/photostream', '/')})();
我基于在下一页中找到的代码所拥有的东西: 简单的Javascript小书签问题
所以可以说我从以下网址开始https://www.flickr.com/photos/nasacommons/7651153916/in/set-72157630766688018
我想在https://www.flickr.com/photos/nasacommons/7651153916/结尾
现在,由于flickr在图片网址之后使用了许多不同的位置引用,而不仅仅是'/ in / photostream',因此我希望代码替换'/ in /'以及其后的所有内容都只包含'/'
谢谢一群!
尝试这个 :-
location.href = location.href.substring(0,location.href.indexOf("in"));
要么
location.href = location.href.substring(0,location.href.lastIndexOf("in"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.