[英]How to open a bootstrap modal from another page?
I have on my Home.asp a login button which opens a modal. 我在Home.asp上有一个登录按钮,用于打开模式。 I have another page which has a login/logout button. 我还有另一个页面具有登录/注销按钮。 How can I call the modal from Home page on this page. 如何在此页面上的主页上调用模态。
Home. 家。 aspx Code: aspx代码:
<a href="#" data-target="#ModalCLogin" data-toggle="modal"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
Second page Code: (Here on this link click I want to call modal from Home.aspx) 第二页代码:(在此链接上,单击“我想从Home.aspx调用模式”)
<a href="#" data-target="#ModalCLogin" data-toggle="modal"><span class="glyphicon glyphicon-log-in"></span> Login</a>
I had the same issue and I found a solution in this link . 我遇到了同样的问题,并且在此链接中找到了解决方案。 Let's say you have 2 pages, 假设您有2页,
First.html --> Contains an anchor to the modal First.html->包含模式的锚点
Second.html --> Contains the definition of your modal Second.html->包含模态的定义
Basically you need to href the location of your modal in "Second.html" and data-target the id of your modal 基本上,您需要在“ Second.html”中对模式的位置进行href设置,并以数据为目标的模式ID
<li><a href="Second.html" data-target="#theModal" data-toggle="modal">Lab 6</a></li>
Then still in your First.html you need to define the modal with the id until the modal-content 然后仍然在First.html中,您需要使用id定义模态,直到modal-content
<div class="modal fade text-center" id="theModal">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
On the Second.html you define what is inside the modal-content 在Second.html上,您定义模态内容内的内容
<div class="modal-header">
...
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
...
</div>
It worked for me. 它为我工作。 All the credits go to Buzinas who answered this question on the link I provided above 所有学分归Buzinas所用 ,他在我上面提供的链接上回答了这个问题
Calling the id of the modal in your other page. 在其他页面中调用模式的ID。
Modal in your Home.aspx: 您的Home.aspx中的模态:
<div id="HomeModalId" data-width="500" data-backdrop="static"> Modal Content </Div>
In your second page, the link would be something like. 在第二页中,链接类似于。
<a href="Home.aspx/#HomeModalId" data-target="#ModalCLogin" data-toggle="modal"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
Your first page: 您的第一页:
<a href="#" data-target="#ModalCLogin" data-toggle="modal"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>`
on the bottom of your first page: 在首页底部:
<div id="ModalCLogin" class="modal fade text-center">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
on your 2nd pages: "your modal" 在您的第二页上:“您的模式”
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="ModalCLogin" class="myModal">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.