使用jquery将值传递给popover上的iframe

时间:2016-06-11 07:23:29

标签: javascript jquery html twitter-bootstrap iframe

我编写了一个代码,用于在悬停链接时显示popover iframe。现在我想将链接值传递给popover上的iframe窗口。我怎样才能做到这一点? 这是我的代码

<a href="#" class="show-pop-iframe btn btn-default " data-placement="vertical" id="sample" value="email@domain.com">email@domain.com </a>
<a href="#" class="show-pop-iframe btn btn-default " data-placement="vertical" id="sample1" value="email1@domain1.com">email1@domain1.com </a>
<div id="auto"></div>               
(function(){
    var settings = {
        trigger:'hover',
        title:'Send Mail To User',
        content:'<p>This is webui popover demo.</p><p>just enjoy it and have fun !</p>',
        width:auto,                     
        multi:true,                     
        closeable:false,
        style:'',
        delay:300,
        padding:true,
        backdrop:false
    };

    function initPopover(){                 
        var iframeSettings = {  
            width:500,
            height:350,
            closeable:true,
            padding:false,
            type:'iframe',                      
            url:'http://localhost/live/liveuser.php'
        };              

        $('a.show-pop-iframe').webuiPopover('destroy').webuiPopover(
            $.extend({},settings,iframeSettings)
        );
    }

    initPopover();
})();

1 个答案:

答案 0 :(得分:1)

function initPopover(){                 
    var iframeSettings = {  
        width:500,
        height:350,
        closeable:true,
        padding:false,
        type:'iframe'
    };              

    $('a.show-pop-iframe').webuiPopover('destroy');
    $.each($('a.show-pop-iframe'), function (key, element) { 
        var url = 'http://localhost/live/liveuser.php';
        url += '?' + encodeURI($(element).attr("value")); // You will get link value in url
        webuiPopover($.extend({url: url},settings,iframeSettings));
    }
}