Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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 如何在重定向请求中忽略域?_Javascript_Jquery - Fatal编程技术网

Javascript 如何在重定向请求中忽略域?

Javascript 如何在重定向请求中忽略域?,javascript,jquery,Javascript,Jquery,我有3个领域,一个用于开发,另一个用于QA,另一个用于生产。 比如说: dev-domain.com qa-domain.com prod-domain.com 我想在用户提交电子邮件后将其发送到另一个位置: window.location.href='confirmation.html' 因此,我希望避免在每个环境中执行以下操作: window.location.href='dev domain.com/confirmation.html'或window.location.href='qa

我有3个领域,一个用于开发,另一个用于QA,另一个用于生产。 比如说:

  • dev-domain.com
  • qa-domain.com
  • prod-domain.com
我想在用户提交电子邮件后将其发送到另一个位置:

window.location.href='confirmation.html'

因此,我希望避免在每个环境中执行以下操作:

window.location.href='dev domain.com/confirmation.html'
window.location.href='qa domain.com/confirmation.html',并且仅执行以下操作:

window.location.href='(测试域)/confirmation.html'


有什么建议吗?

文件名.html
应该足够了,因为它是相对路径。您需要实现绝对路径吗?

文件名.html
应该足够了,因为它是相对路径。是否需要实现绝对路径?

窗口。位置有几个属性,如主机、协议、端口等-

您可以仅更改位置对象的路径:

window.location.pathname = '/confirmation.html';

window.location
有几个属性,如主机、协议、端口等-

您可以仅更改位置对象的路径:

window.location.pathname = '/confirmation.html';

是的,正如前面指出的那样,
window.location.hostname
属性返回(当前页面的)internet主机的名称

因此,您可以使用:
window.location.href=window.location.hostname+'/confirmation.html'

是,正如前面指出的那样,
window.location.hostname
属性返回(当前页面的)internet主机的名称

因此,您可以使用:
window.location.href=window.location.hostname+'/confirmation.html'

window.location.hostname+'/confirmation.html'
window.location.hostname+'/confirmation.html'