Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从另一页打开引导模式_Javascript_Jquery_Html_Twitter Bootstrap_Modal Dialog - Fatal编程技术网

Javascript 从另一页打开引导模式

Javascript 从另一页打开引导模式,javascript,jquery,html,twitter-bootstrap,modal-dialog,Javascript,Jquery,Html,Twitter Bootstrap,Modal Dialog,我有一个链接列表,每个链接都打开自己的模式。每个modals内容都显示一个html文件。这是一个样本 <div id="how-rtm-works" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"&g

我有一个链接列表,每个链接都打开自己的模式。每个modals内容都显示一个html文件。这是一个样本

<div id="how-rtm-works" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
<div class="modal-content">
 <div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h1 id="myModalLabel">How Right to Manage works</h1>
</div>
<div class="modal-body" id="utility_body">
<p>One fine body…this is getting replaced with content that comes from passed-in href</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<li><a data-target="#how-rtm-works" href="modal-content/how-RTM-works.html" role="button" data-toggle="modal">How Right to Manage works</a></li>
由于存在多个模态,因此每个模态都有自己的ID,该ID在数据目标中引用


有谁能告诉我如何从另一个页面定位这些模态,或者在我的情况下,所有页面都将链接到网站页脚导航中。

你的模态有ID,我想你可以通过在链接末尾添加rtm的工作方式来触发它们 例如,如果您有一个名为 id=我的 你可以建立一个链接
如果这是你的问题,我想这可以帮你解决

你的modals有id,我想你可以通过在链接末尾添加rtm的工作方式来触发它们 例如,如果您有一个名为 id=我的 你可以建立一个链接 如果这是你的问题,我想这可以帮你解决

您将使用的第一页:

<a href="second.html#myModalLabel" class="btn btn-primary"> Open Modal </a>
在第二页,您将插入模态和以下脚本:

        <script type='text/javascript'>
            (function() {
                'use strict';
                function remoteModal(idModal){
                    var vm = this;
                    vm.modal = $(idModal);

                    if( vm.modal.length == 0 ) {
                        return false;
                    }

                    if( window.location.hash == idModal ){
                        openModal();
                    }

                    var services = {
                        open: openModal,
                        close: closeModal
                    };

                    return services;
                    ///////////////

                    // method to open modal
                    function openModal(){
                        vm.modal.modal('show');
                    }

                    // method to close modal
                    function closeModal(){
                        vm.modal.modal('hide');
                    }
                }
                Window.prototype.remoteModal = remoteModal;
            })();

            $(function(){
                window.remoteModal('#myModalLabel');
            });
        </script>
您将使用的第一页:

<a href="second.html#myModalLabel" class="btn btn-primary"> Open Modal </a>
在第二页,您将插入模态和以下脚本:

        <script type='text/javascript'>
            (function() {
                'use strict';
                function remoteModal(idModal){
                    var vm = this;
                    vm.modal = $(idModal);

                    if( vm.modal.length == 0 ) {
                        return false;
                    }

                    if( window.location.hash == idModal ){
                        openModal();
                    }

                    var services = {
                        open: openModal,
                        close: closeModal
                    };

                    return services;
                    ///////////////

                    // method to open modal
                    function openModal(){
                        vm.modal.modal('show');
                    }

                    // method to close modal
                    function closeModal(){
                        vm.modal.modal('hide');
                    }
                }
                Window.prototype.remoteModal = remoteModal;
            })();

            $(function(){
                window.remoteModal('#myModalLabel');
            });
        </script>


我想我不明白你的要求。。。你想在一个页面上打开另一个页面上的模式吗?我在一个网页上有五个链接,每个链接都打开自己的模式。我之所以这样做,是因为我无法确定如何对所有链接使用一个模式。我希望在我的模板页脚以及包含Modals的页面上都有这些链接,因此,如果用户从另一个页面单击页脚中的链接,他们将被定向到包含Modals的页面并打开Modals。为什么不像普通网站一样创建单独的页面呢?/我理解你的观点!主要原因是,我们想让用户从这个特定的页面获得某些信息,但不想让他们偏离我们试图引导他们通过的自然路径。我开始觉得我们把事情复杂化了!哈哈哈!我想你可能是,你为什么不用手风琴?我想我不明白你的要求。。。你想在一个页面上打开另一个页面上的模式吗?我在一个网页上有五个链接,每个链接都打开自己的模式。我之所以这样做,是因为我无法确定如何对所有链接使用一个模式。我希望在我的模板页脚以及包含Modals的页面上都有这些链接,因此,如果用户从另一个页面单击页脚中的链接,他们将被定向到包含Modals的页面并打开Modals。为什么不像普通网站一样创建单独的页面呢?/我理解你的观点!主要原因是,我们想让用户从这个特定的页面获得某些信息,但不想让他们偏离我们试图引导他们通过的自然路径。我开始觉得我们把事情复杂化了!哈哈哈!我想你可能是,为什么不用手风琴呢?我试试这个。。谢谢你的建议,穆罕默德!事实上,我不知道该怎么做,因为我的modals内容是href标记中引用的外部html文件,而modal id在data target标记中引用。我这样做是为了使页面不会一直在页面中嵌入大量html。但是,如果我想从页面外部用modals链接到它们,这可能是唯一的方法。我现在已经尝试过了,但它仍然没有打开modalswell。你可以发送你网站的链接来检查吗?保存modals的页面可以在:test-site.rtmf.org.uk/services-retirement.php I上查看希望能够在其他网页上从页脚nag中的相关链接打开它们。我将尝试此。。谢谢你的建议,穆罕默德!事实上,我不知道该怎么做,因为我的modals内容是href标记中引用的外部html文件,而modal id在data target标记中引用。我这样做是为了使页面不会一直在页面中嵌入大量html。但是,如果我想从页面外部用modals链接到它们,这可能是唯一的方法。我现在已经尝试过了,但它仍然没有打开modalswell。你可以发送你网站的链接来检查吗?保存modals的页面可以在:test-site.rtmf.org.uk/services-retirement.php I上查看希望能够在其他网页上从页脚nag中的相关链接打开它们。不知道为什么我三年前从未尝试过。有一个类似的问题,并尝试了这个完美的工作。很多迟来的感谢Burunohn不知道为什么我在三年前没有尝试过这个。有一个类似的问题,并尝试了这个完美的工作。非常迟来的感谢burunoh