Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果word以开头,则替换url_Javascript_Jquery_Html_Regex_Replace - Fatal编程技术网

Javascript 如果word以开头,则替换url

Javascript 如果word以开头,则替换url,javascript,jquery,html,regex,replace,Javascript,Jquery,Html,Regex,Replace,如果单词以getlink开头,我想替换url download file: xxxxxxxxxx.com getlink file: xxxxxxxxxx.com 仅将xxxxxxxxx.com替换为mmmm 111.com 如何使用JavaScript实现这一点?只需使用window.location.href获取当前页面的url即可 在javascript代码的内部,有一些代码如下所示 if (window.location.href == "xxxxxxx.com") {

如果单词以getlink开头,我想替换url

  download file: xxxxxxxxxx.com 

  getlink file:  xxxxxxxxxx.com
仅将xxxxxxxxx.com替换为mmmm 111.com


如何使用JavaScript实现这一点?

只需使用window.location.href获取当前页面的url即可

在javascript代码的内部,有一些代码如下所示

if (window.location.href == "xxxxxxx.com") {
   location = "mmmmmmmmmm111.com"
}

如果你能更具体一些,包括一些更详细的解释和代码,这将是一个bg帮助。

请分享你的尝试,并描述你面临的问题。@gurvinder372我不想手动替换多个链接。请更具体、更清楚地说明你发布的问题。他只想在有词出现时替换(询问者没有说明他是如何获得的)不是每个
位置都以“getlink”开头。href
Ok没有意识到这一点。