Javascript重定向 - 删除父位置 [英] Javascript redirect - remove parent location
问题描述
我正在使用 javascript 表单脚本,我想重定向到外部网站.我将重定向设置为 www.paypal.me 但它实际上将用户重定向到 www.mysite.com/www.paypal.me
I am using a javascript form script and I want to redirect to an external website. I set the redirect to www.paypal.me but it actually redirects the user to www.mysite.com/www.paypal.me
如何编辑下面的代码以将用户重定向到实际站点,而不是以我自己的 URL 开头?
How can I edit the code below to instead redirect the user to the actual site, not prefaced by my own URL?
var redirect = "www.paypal.me";
...
this.submitOK = function(){
if( redirect == '' ){
showThankYouMessage();
return;
};
try{
if( parent ) parent.location.href = redirect;
}catch(e){
location.href = redirect;
};
}
}
推荐答案
在这里你可以找到一个关于 js 重定向方法的小概述:https://appendto.com/2016/04/javascript-redirect-how-to-redirect-a-web-page-with-javascript/
Here you can find a small overview over the redirect methods in js: https://appendto.com/2016/04/javascript-redirect-how-to-redirect-a-web-page-with-javascript/
重定向使用如下:
<script>
var locationn = "https://google.com";
window.location = locationn;
这篇关于Javascript重定向 - 删除父位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!