将Fancybox中的数据变量传递给iframe

时间:2015-12-09 22:20:45

标签: javascript php jquery iframe

我正在尝试但未能通过JS将变量传递给iframe。框架的目的如下。如果已点击的网址不在安全列表中,我会打开一个安全外部网址列表,然后打开一个带有特殊消息的fancybox,提醒用户他们点击的链接不会在网站的意见或视图中共享。 iframe中还有一个继续按钮,它们最初点击的url使用了php echo $ _GET ['dest'];获取网址形成iframe网址。

以下代码适用于Chrome,但在FF和IE中我得到了

禁 您无权访问此服务器上的/wp-content/themes/mytheme/third-party-alert.php。

我不知道如何解决禁止的消息,所以我想我可以尝试传递他们在Fancybox的数据属性中点击的网址,然后在iframe中重复使用它。我已尝试多次尝试传递数据但仍然失败。如何将他们点击的网址数据传递给iframe(这只是一个显示为iframe的网页),并将其用作iframe页面中的href链接,以便用户希望继续使用iframe单击按钮。

jQuery(document).ready(function() {
// Put anonymous functions and other stuff in here.

  // qTip notice of external link
  jQuery.each(jQuery('a'),function(){
    // Check if it's a URL not owned/operated by GBFCU
    var url = jQuery(this).attr('href');
    url = (url==null) ? '' : url.split('://');
    if(url.length>1){
        url = url[1].split('/');
        // List the "safe URLs" here.
        if(url[0]!= 'www.safeurl.org' &&
            url[0]!= 'safeurl.org' &&
            url[0]!= 'lastsafeurl.net' 
            ){  
                // Display confirmation for "not safe" URLs.
                var dest = jQuery(this).attr('href');                   
                dest = encodeURIComponent(dest);
                jQuery(this).on('click',function(){
                    var speciallink = dest;

                        jQuery.fancybox( {
                            href : '/wp-content/themes/mytheme/third-party-alert.php?dest='+dest,
                            type : 'iframe',
                            padding : 0,
                            autoSize : false,
                            width: '600px',
                            height : '520px',
                            scrolling : 'no',
                            data : dest                 
                        });                             

                    return false;
                });                 

                jQuery(this).attr('target','_blank');               
        }//if not safe...
    }//if it's an http:// link      
});//iterate through all the hyperlinks on the page 
});

0 个答案:

没有答案
相关问题