我尝试使用弹出窗口进行登录,但它无法在IE或Mozilla Firefox中运行。我用过JS,HTML和CSS ......
<a href="javascript:void(0)" class="hiddenlink" onclick="toggle_visibility('logBox');">Log In</a>
有JS
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
并且有css
.boxPosition{
position: absolute;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.7);
display: none;
width: 100%;
height: 100%;
}
我不知道问题出在哪里......
感谢您的帮助
答案 0 :(得分:1)
下面没有错误,但要避免它以防止错误!
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block') {//<-------CORRECT THIS {
e.style.display = 'none';
} else { //<-------------------------------CORRECT THIS {}
e.style.display = 'block';
}//<---------------------------------------CORRECT THIS }
}
下面的测试似乎没问题(没问题,它隐藏了#34; logBox&#34;)! 我使用Firefox
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block') {//<-------CORRECT THIS {
e.style.display = 'none';
} else { //<-------------------------------CORRECT THIS {}
e.style.display = 'block';
}//<---------------------------------------CORRECT THIS }
}
&#13;
.boxPosition{
position : absolute;
top : 0;
left : 0;
background-color: rgba(0,0,0,0.7);
display : none;
width : 100%;
height : 100%;
}
&#13;
<a href="javascript:void(0)" class="hiddenlink" onclick="toggle_visibility('logBox');">Log In</a>
<!--
Maybe your issue come from the part below
we haven't
-->
<div id='logBox' style='display : block;'>
I am the LogBox<br>
Name : <input type='text'/><br>
Pass :<input type='password'/><br>
</div>
&#13;
总之:
也许问题不是来自你发布的内容,这似乎没问题!
答案 1 :(得分:0)
您可能必须使用jQuery来执行弹出窗口。你有任何Javascript 经验?制作模态可能会有所帮助,这是我使用它的唯一方法。