欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

在iframe中使bootstrap的模態(tài)框在父頁(yè)面彈出問(wèn)題

 更新時(shí)間:2017年08月07日 15:41:14   作者:Yan-D  
這篇文章主要介紹了在iframe中使bootstrap的模態(tài)框在父頁(yè)面彈出問(wèn)題,解決方法非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

這幾天在寫(xiě)項(xiàng)目的中,頁(yè)面使用了iframe,然而在子頁(yè)面中使用bootstrap的模態(tài)框時(shí)發(fā)現(xiàn):彈出的模態(tài)框位置是以子頁(yè)面為標(biāo)準(zhǔn)居中的,并且遮罩層也只有子頁(yè)面那一部分,整個(gè)頁(yè)面簡(jiǎn)直無(wú)法直視,所以思考可以可以讓模態(tài)框以父頁(yè)面為標(biāo)準(zhǔn)彈出,經(jīng)過(guò)在網(wǎng)上查找資料,總結(jié)了一種解決方法。

效果展示

修改前頁(yè)面

這里寫(xiě)圖片描述

修改后頁(yè)面

這里寫(xiě)圖片描述

實(shí)現(xiàn)思路

要想使模態(tài)框在頂級(jí)頁(yè)面打開(kāi),我想到的方法是使bootstrap的模態(tài)框彈在父頁(yè)面彈出即可。

首先我們將需要彈出的div單獨(dú)寫(xiě)一個(gè)頁(yè)面,當(dāng)子頁(yè)面需要彈出時(shí),在父頁(yè)面彈出div即可。

將模態(tài)框單獨(dú)寫(xiě)為一個(gè)頁(yè)面

主頁(yè)面

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title></title>
  </head>
  <body>
    <div class="modal fade" id="ajax" role="basic" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
        </div>
      </div>
    </div>
  </body>
  <script>
      $("#ajax").modal({
        remote: "./model.html"
      });
  </script>
</html>

模態(tài)框頁(yè)面

<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title" id="myModalLabel">Modal title</h4>
  </div>
  <div class="modal-body">
    這是模態(tài)框
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-primary">保存</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button>
  </div>
</div>

這樣就可以將模態(tài)框的div單獨(dú)寫(xiě)為一個(gè)頁(yè)面

修改主頁(yè)面,加入子頁(yè)面

修改后主頁(yè)面

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title></title>
  </head>
  <body>
    <table width="100%" height="720px" border="1">
      <tr>
        <td>
          <iframe id="iframe1" name="iframe1" src="iframe1.html" width="100%" height="100%"></iframe>
        </td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td>
          <iframe name="iframe2" src="iframe2.html" width="100%" height="100%"></iframe>
        </td>
      </tr>
    </table>
    <input type="text" id="textId" value="234" />
    <div class="modal fade" id="ajax" role="basic" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
        </div>
      </div>
    </div>
  </body>
  <script>
    function modalOut(url) {
      $("#ajax").modal({
        remote: url;
      });
    }
  </script>
</html>

這樣主頁(yè)面就有2個(gè)子頁(yè)面,并且將彈出模態(tài)框的方法封裝至modalOut(url)方法中

子頁(yè)面彈出模態(tài)框

當(dāng)子頁(yè)面需要彈出模態(tài)框時(shí),加載父頁(yè)面中的modalOut(url)方法即可:

子頁(yè)面js如下

var _iframe = window.parent;
_iframe.modalOut('xxx.html');

以上就是解決子頁(yè)面中彈出模態(tài)框無(wú)法覆蓋全部頁(yè)面的解決辦法,

注意:所以html中未加載js,請(qǐng)自行加載bootstrap相關(guān)的js。

總結(jié)

以上所述是小編給大家介紹的在iframe中使bootstrap的模態(tài)框在父頁(yè)面彈出問(wèn)題,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論