用小书签替换当前URL的结尾字符 [英] Replace end characters of current URL with bookmarklet

查看:77
本文介绍了用小书签替换当前URL的结尾字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过javascript小书签用另一个字符串替换currentURL中最后一个反斜杠之后的所有字符?

Is there a way to replace all characters after the last backslash in the currentURL with another string via javascript bookmarklet?

我正在对SharePoint网站进行大量审核工作,并且必须通过在URL末尾输入字符串来手动查看网站的设置页面.例如,我可能会去像这样的网站:

I'm doing a lot of auditing work with Sharepoint sites and having to manually look at the settings pages for sites by entering strings to the end of a URL. For example, I might go to a site like:

https://site.com/..../default.aspx

然后将"default.aspx"替换为"_layouts/user.aspx",然后重新加载新页面,使其现在位于:

And I replace the "default.aspx" with "_layouts/user.aspx" and reload the new page so it is now at:

https://site.com/..../_layouts/user. aspx

它并不总是"default.aspx",因此我不能仅使用简单的字符串替换.我知道有一种方法可以通过javascript小书签来操作URL,但是我对此的知识充其量是有限的.任何帮助或指导将不胜感激

It's not always "default.aspx", so I can't just use a simple string replace. I know there is a way to manipulate the URL via a javascript bookmarklet, but my knowledge of how to do that is limited at best. Any help or guidance would be greatly appreciated

推荐答案

我不知道这是否是您的想法,但是如果您只想用其他方式更改url的最后一部分,则可以使用此功能小书签

I don't know if this is what you thought, but if you just want to change the last part of the url with something else, you could use this bookmarklet

javascript:(function(){ 

var curloc = document.location.href.split('/');
var urlEnding= '/_layouts/user.aspx';
curloc = curloc.splice(0,curloc.length-1).join('/')+urlEnding;
document.location.href = curloc;

})();

您可以将固定网址替换为

You could replace the fixed url with

prompt('Enter your url:', '_layouts/user.aspx');

如果您需要每次更改最后一部分.

if you need to change the last part each time.

我希望这会有所帮助.

这篇关于用小书签替换当前URL的结尾字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆