A.html
<div class="X"></div>
<div class="Y"></div>
B.html
<iframe scrolling="no" src="A.html">
当用户访问A.html时设置div Y为display: none
当用户访问B.html时设置div X为display: none
最佳答案
只需在 A.html 中使用此脚本,我希望您会得到想要的结果!
<script type="text/javascript">
$(document).ready(function () {
var path = window.location.pathname;
var ref = document.referrer;
if (path == '/A.html' && ref!='')
{
$('[class="Y"]').css('display', 'none');
}
else {
$('[class="X"]').css('display', 'none');
}
});
</script>
关于javascript - 在 iframe 中更改 css 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47107870/