【发布时间】:2018-11-05 14:53:46
【问题描述】:
我需要获取完整的网址
我需要从停在同一个基本域站点的登录页面上的域交叉。
我有一个这样的 URL 示例:登录页面 http://landing.name 跨到基本域 http://domain.name/test.html
我需要手动定义完整的 URL
我的代码:
$('.add-it').click(function(ev) {
ev.preventDefault();
var uri = $(this).attr('href');
$.get( uri, function( r ) {
swal({
title: "Test Title!",
text: r + "Test",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Test",
cancelButtonText: "Test",
closeOnConfirm: true,
closeOnCancel: true,
html: true
}, function(isConfirm) {
if (isConfirm) {
document.location.href = '/test.html';
}
});
}).fail(function(xhr, status, error) {
swal({ title: 'woops', text: error, type: "warning", }); // or whatever
});
return false;
});
实际代码运行良好,但没有完整的 URL
我试着改变
document.location.href = '/test.html';
到
location.href = 'http://domain.name/test.html';
window.location.href = 'http://domain.name/test.html';
但不起作用。
请帮忙? 非常感谢。
【问题讨论】:
-
请指定您要执行的操作,因为设置
document.location.href工作正常。 -
嗨 Domenik,我需要从停在同一个基本域中的登录页面上的域交叉我有这样的 URL 示例:登录页面 landing.name 交叉到基本域 domain.name/test.html跨度>
-
在控制台中尝试
window.location.href = 'http://domain.name/test.html';,例如。 google.com,它的工作原理。