次のURLに行くと、アラートは機能しませんでした。ウィンドウの位置onchangeで3minsごとにウィンドウのhref値を取得する必要があります。3分ごとにウィンドウのhref値を知る方法
var i=0;
function load(){
var currentLoc = window.location.href;
PrevLoc = currentLoc;
interval(currentLoc,PrevLoc);
}
function interval(currentLoc,PrevLoc){
setInterval(function() {
if(currentLoc == 'https://github.com/features'){
\t \t alert('Reached the Target Page')
// document.write('Reached the Target Page');
return true;
}
if(currentLoc == PrevLoc){
\t alert(window.location.href);
// document.write(window.location.href);
if(i==0){
PrevLoc = window.location.href;
window.location.href = "https://github.com/join?source=login";
currentLoc=window.location.href;
}
interval(currentLoc,PrevLoc);
i++;
}
else {
\t alert(window.location.href);
// document.write(window.location.href);
}
},3000);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> </script>
<body onLoad="load();">
</body>
私には、JavaScriptとjQueryのsetIntervalを使用して、これをしようとしています。 hrefの値が変更されたときに機能しませんでした。
<html>
<head>
</head>
<body onLoad="load();">
<script>
function load(){
window.location.href = "https://github.com/join?source=login"
var PrevLoc = "https://github.com/join?source=login";
var currentLoc = window.location.href;
if(currentLoc == PrevLoc){
alert('inside')
setInterval(function() {
alert('changed')
},3000);
}
else {
}
}
</script>
</body>
</html>
window.location.href。 – Arun