在从其他网站重定向时显示网页,并且在此过程中URL会更改为指向其他端口号。
我的代码是:
if (window.location.href === "http://abc123.net.au:2048 ") {
$(function () {
try {
opera.setOverrideHistoryNavigationMode('compatible');
history.navigationMode = 'compatible';
}
catch (e) {
}
function OnBeforeUnload() {
$(window).onbeforeunload;
// Post to script that will log the user out
xmlhttp.open("POST", "../logscript.php", true);
xmlhttp.send();
}
function ReturnMessage() {
return "Wait, by closing this session I will end your session. You will be required to log in again t access the site.";
}
function UnBindWindow()
{
$(window).unbind('beforeunload', ReturnMessage);
}
$(window).bind('beforeunload', ReturnMessage);
});
} else {
document.write('<div>code is not working</div>')
}
答案 0 :(得分:0)
这是你的第二个答案
window.onbeforeunload = bunload;
function bunload(){
dontleave="Are you sure you want to leave?";
return dontleave;
}
答案 1 :(得分:-1)
if(window.location.pathname.indexOf("abc123.net.au")) {
{
//test
alert("your url contains this abc123.net.au");
}
function UnLoadWindow() {
return 'We strongly recommends NOT closing this window yet.'
}
window.onbeforeunload = UnLoadWindow;
function OnBeforeUnload()
{
window.onbeforeunload;
// Post to script that will log the user out
xmlhttp=new XMLHttpRequest(); }
xmlhttp.open("POST","../logscript.php",true);
xmlhttp.send();
alert("POSTING NOW");
function handleWindowClose()
{
if((window.event.clientX<0) || (window.event.clientY<0))
{
event.returnValue = "Wait, by closing this session I will end your session.";
}
}
}else{
}