如何从另一个页面打开引导模态? [英] How to open a bootstrap modal from another page?

查看:43
本文介绍了如何从另一个页面打开引导模态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Home.asp上有一个登录按钮,用于打开模式.我还有另一个页面具有登录/注销按钮.如何在此页面上的主页上调用模态.

I have on my Home.asp a login button which opens a modal. I have another page which has a login/logout button. How can I call the modal from Home page on this page.

首页.aspx代码:

<a href="#" data-target="#ModalCLogin" data-toggle="modal"><span class="glyphicon glyphicon-log-in"></span>&nbsp;Login</a></li>

第二页代码:(在此链接上,单击我想从Home.aspx调用模式")

Second page Code: (Here on this link click I want to call modal from Home.aspx)

<a href="#" data-target="#ModalCLogin" data-toggle="modal"><span class="glyphicon glyphicon-log-in"></span>&nbsp;Login</a>

推荐答案

我遇到了同样的问题,并且在

I had the same issue and I found a solution in this link. Let's say you have 2 pages,

  • First.html->包含模式的锚点

  • First.html --> Contains an anchor to the modal

Second.html->包含模态的定义

Second.html --> Contains the definition of your modal

基本上,您需要 href 模态在"Second.html"中的位置,并 data-target 模态的ID

Basically you need to href the location of your modal in "Second.html" and data-target the id of your modal

<li><a href="Second.html" data-target="#theModal" data-toggle="modal">Lab 6</a></li>

然后仍然在First.html中,您需要使用 id 定义模式,直到 modal-content

Then still in your First.html you need to define the modal with the id until the modal-content

<div class="modal fade text-center" id="theModal">
 <div class="modal-dialog">
  <div class="modal-content">
  </div>
 </div>
</div>

在Second.html上,您定义 modal-content

On the Second.html you define what is inside the modal-content

<div class="modal-header">
  ...
</div>
<div class="modal-body">
  ...
</div>
<div class="modal-footer">
  ...
</div>

对我有用.所有的功劳归于 Buzinas ,他们在我上面提供的链接上回答了这个问题

It worked for me. All the credits go to Buzinas who answered this question on the link I provided above

这篇关于如何从另一个页面打开引导模态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆