gpt4 book ai didi

javascript - jquery查看iframe位置是否改变

转载 作者:行者123 更新时间:2023-11-28 01:56:15 25 4
gpt4 key购买 nike

所以我想检查我的框架位置是否已更改

function myFunction()
{
setInterval(function(){alert("Hello")},3000);

if (document.getElementById("myiframe").src = 'http://www.constant-creative.com/login';)
{
}
else
{
$( "#loginframe" ).hide();
}
}

这就是我目前所拥有的

最佳答案

在 JavaScript 中,=assignment operator 。例如

// foo can be whatever
foo = 'bar'
// now foo is 'bar'

但是如果您想比较事物,请使用comparison operators ==(相等运算符)或===(严格相等运算符)。不同之处在于 == 仅比较值,而 === 比较值和类型。例如

var a = 1;
a == 1; // yes
a === 1; // yes
a == true; // yes
a === true; // NO!
// a is still 1

如果您想对比较运算符求反(即知道两个事物是否不同),您可以使用 !=!==。例如,

1 !=  1;     // no
1 !== 1; // no
1 != true; // no
1 !== true; // YES!

如果您知道要比较的事物的类型相同,则 ===== 将具有相同的行为,但 === 会更快。

<小时/>

就您而言,您可以使用类似的内容

function myFunction()
{
if (document.getElementById("myiframe").src
!==
'http://www.constant-creative.com/login';
) {
$( "#loginframe" ).hide();
}

setTimeout(myFunction,3000);
}
myFunction();

关于javascript - jquery查看iframe位置是否改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19072308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com