在jquery simplemodal中显示url中的内容

Display content from url inside jquery simplemodal

本文关键字:url 显示 jquery simplemodal      更新时间:2023-09-26

我想加载这个内容https://www.paypal.com/uk/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside在jquery simplemodal对话框

我该怎么做呢?

我试过这个例子:

$('#paypal-popup').click(function (e) {
            var src = "http://365.ericmmartin.com/";
            $.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
                closeHTML: "",
                containerCss: {
                    backgroundColor: "#fff",
                    borderColor: "#fff",
                    height: 450,
                    padding: 0,
                    width: 830
                },
                overlayClose: true
            });
        });

,它是为我工作,但如果我改变src url https://www.paypal.com/uk/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside它是重定向我那里。

我该如何解决这个问题?

无论你使用什么库,你不能在iframe中加载url的内容。
肯定会被重定向,因为其中有一个小脚本在运行。

如果你查看该页的源代码你可以看到这个

<style type="text/css" id="antiClickjack">
    body{display:none !important;}
</style>
<script type="text/javascript"> 
    if (self === top) {
        var antiClickjack = document.getElementById("antiClickjack");
        antiClickjack.parentNode.removeChild(antiClickjack);
    } 
    else {
        top.location = self.location;
    }
</script>

这意味着如果页面在iframe中,隐藏内容并将页面位置更改为iframe的位置
它是用来防止点击劫持的

如果你想在iframe中显示任何其他站点,只需使用jQuery UI Dialog。
演示:http://jsfiddle.net/naveen/C6rR2/1/

你可以在你的代码中添加一个jquery插件

看到~http://fancybox.net/

http://jquery.com/demo/thickbox/