问题:
控制台中有0个错误,但我无法实时获取mRegistration.location.href
。我应该使用当前网址进入#creatingButton
按钮文本内,但我只有about:blank
并停止获取网址。
注意:http://zareklamy.pl
重定向到https://zareklamy.com/
,所以我应该在按钮内输入https://zareklamy.com/
作为文本。
<script>
var mRegistration;
var aLeft = (screen.width / 1.5) - (screen.width / 2);
var aTop = (screen.height / 1.65) - (screen.height / 2);
var mRegistrationParams = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=' + screen.width / 1.5 + ', height=' + screen.height / 1.5 + ', top=' + aTop + ', left=' + aLeft;
function startRegistration() {
if (mRegistration) {
emptyWindow();
} else {
emptyWindow();
openWin()
}
}
function emptyWindow() {
mRegistration = window.open("http://zareklamy.pl", 'zareklamy_' + Math.floor(Math.random() * 1e10), mRegistrationParams);
}
function openWin() {
if (!mRegistration || mRegistration.closed) {} else {
$.ajax({
url: 'process.php',
type: 'POST',
cache: false,
data: 'get=1',
success: function(a) {
switch (a) {
case 'NO_SITE':
emptyWindow();
location.reload(true);
break;
default:
var b = jQuery.parseJSON(a);
if (mRegistration.location.href == 'https://zareklamy.com/') {
alert("Good url");
} else {
alert("Bad url");
}
setInterval(function() {
$('#creatingButton').html(mRegistration.location.href);
}, 1000);
break
}
}
});
}
}
</script>
<button id="creatingButton" onclick="javascript:startRegistration()">Open popup</button>