javascript - 如果单词以开头,则替换 url
问题描述
如果单词以getlink开头,我想替换 url 。
download file: xxxxxxxxxx.com
getlink file: xxxxxxxxxx.com
仅将 xxxxxxxxxx.com 替换为 mmmmmmmm111.com
我怎样才能使用 JavaScript 做到这一点?
解决方案
只需使用 window.location.href 即可获取当前页面的 url。
在您的 javascript 代码中只有一些看起来像这样的代码
if (window.location.href == "xxxxxxx.com") {
location = "mmmmmmmmmm111.com"
}
如果您可以更具体并包含一些更详细的解释和代码,那将是一个帮助。
推荐阅读
- angular - 如何在Angular中显示分组数组?
- javascript - Javascript/Javascript 中的多级过滤
- html - 在 flexbox 网格中,如何防止第一行向下推第二行?
- angular - 从多个组件更新服务中变量的值
- python - 数据更改时如何将“增量”值重置为 1?
- python - Pydrive:更改共享驱动器上文件的元数据
- ios - 如何检测应用内购买过程是否正在进行?
- sql-server - 将 Loopback 4 过滤器转换为 SQL where 子句
- python - 如何在 Python 中向 Google 上的操作发送响应?
- batch-file - 从列表文件中远程获取序列号和型号并导出到排列好的excel