我在页面顶部有两个链接..当我点击链接时,我希望它能够打开一个弹出框(我能够关闭)和给定的信息。现在,如果我点击链接,它将把我带到页面上的那个部分,但是我无法点击第二个链接,除非我一直滚动到页面顶部。
以下是我现在的情况: (我输入的点表示弹出功能之间有代码;基本上相同的div框一遍又一遍,每个只有不同的通道编号)
<p style="font-size:16px"> Changed channels: <a href="#001" data-rel="popup">031</a>
(我删除了第二个链接以避免混淆)
.
.
.
.
.
.
<div id="LayoutDiv3">
<div data-role="popup" id="001">
<div id="Leftbox">001</div>
<div id="chan_logo" style="max-width: 30%"><img src="imgs/chan_logo_01.png" alt="hello"></div>
<div id="chan_title">
<br>
.
.
.
</div>
(please assume the number of div's are all accounted for)
答案 0 :(得分:1)
我希望您能在下面的代码中找到您的问题解决方案。
<a href="#" onclick="GetPopUp(); return false;" > Click Here </a>
您应该在html代码中编写用于创建弹出设计的代码。这始终是display:none
。
现在为弹出窗口编写JavaScript代码。
function GetPopUp(){
$('#divid').dialog(function(){
title : 'new pop up',
height : 500,
width : 1000,
model : true
});
}
答案 1 :(得分:1)
也许是这样的(请考虑将css类设为代替):
Properties
其他解决方案:
<script>
function openPopup() {
popup = document.getElementById("myPopup");
popup.style.display = "block";
}
function closePopup() {
popup = document.getElementById("myPopup");
popup.style.display = "none";
}
</script>
<style>
#myPopup {
display: none;
position: absolute;
top:50px;
right:50%;
background-color: blue;
height:100px;
width:100px;
}
#myExit {
position: absolute;
right:0px;
text-align: right;
color:white;
background-color: red;
}
</style>
<a href="#" onclick="openPopup(); return false;">Open Popup</a>
<div id="myPopup">
<a href="#" id="myExit" onclick="closePopup();return false">x</a>
Hello There
</div>
答案 2 :(得分:0)
那么打开弹出窗口的代码究竟在哪里?
你必须创建一个Javascript函数,它创建一个新的&#34;窗口&#34;上课并打开它。
之后,您必须将 onClick =&#34;&gt; nameOfJSFunction&lt;&#34; 属性添加到元素中。
例如:
<a href="#" onClick="openPopup()">Open a new Popup</a>
然后JS部分:
<script>
function openPopup()
{
newPOPUP = window.open('>LINKtoPOPUPfile<', '>TITLE<', '>OPTIONS<');
newPOPUP.focus();
}
</script>
弹出代码打开的文件应该包含您想要在弹出窗口中看到的代码/元素。