Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.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突破iFrame_Javascript_Iframe_Paypal - Fatal编程技术网

使用Javascript突破iFrame

使用Javascript突破iFrame,javascript,iframe,paypal,Javascript,Iframe,Paypal,编辑(重新措辞):网站加载在iframe中,但iframe中有一个链接,我想在用户单击iframe时将其带出iframe,返回iframe下的主窗口 我找到了 top.location.href = 'page.htm'; ,但我不知道如何将其输入到这个“复杂”代码中 这是我认为应该保存的文件: {literal} $(document).ready( function() { $('#payment_paypal_express_checkout').click(function

编辑(重新措辞):网站加载在iframe中,但iframe中有一个链接,我想在用户单击iframe时将其带出iframe,返回iframe下的主窗口

我找到了

top.location.href = 'page.htm';
,但我不知道如何将其输入到这个“复杂”代码中

这是我认为应该保存的文件:

{literal}

$(document).ready( function() {

    $('#payment_paypal_express_checkout').click(function() {
        $('#paypal_payment_form').submit();
        return false;
    });

    $('#paypal_payment_form').live('submit', function() {
        var nb = $('#quantity_wanted').val();
        var id = $('#idCombination').val();

        $('#paypal_payment_form input[name=quantity]').val(nb);
        $('#paypal_payment_form input[name=id_p_attr]').val(id);
    });

    function displayExpressCheckoutShortcut() {
        var id_product = $('input[name="id_product"]').val();
        var id_product_attribute = $('input[name="id_product_attribute"]').val();

        $.ajax({
            type: "GET",
            url: baseDir+'/modules/paypal/express_checkout/ajax.php',
            data: { get_qty: "1", id_product: id_product, id_product_attribute: id_product_attribute },
            cache: false,
            success: function(result) {
                if (result == '1') {
                    $('#container_express_checkout').slideDown();
                } else {
                    $('#container_express_checkout').slideUp();
                }
                return true;
            }
        });
    }

    $('select[name^="group_"]').change(function () {
        displayExpressCheckoutShortcut();
    });

    $('.color_pick').click(function () {
        displayExpressCheckoutShortcut();
    });

    {/literal}
    {if isset($paypal_authorization)}
    {literal}

        /* 1.5 One page checkout*/
        var qty = $('.qty-field.cart_quantity_input').val();
        $('.qty-field.cart_quantity_input').after(qty);
        $('.qty-field.cart_quantity_input, .cart_total_bar, .cart_quantity_delete, #cart_voucher *').remove();

        var br = $('.cart > a').prev();
        br.prev().remove();
        br.remove();
        $('.cart.ui-content > a').remove();

        var gift_fieldset = $('#gift_div').prev();
        var gift_title = gift_fieldset.prev();
        $('#gift_div, #gift_mobile_div').remove();
        gift_fieldset.remove();
        gift_title.remove();

    {/literal}
    {/if}
    {if isset($paypal_confirmation)}
    {literal}

        $('#container_express_checkout').hide();

        $('#cgv').live('click', function() {
            if ($('#cgv:checked').length != 0)
                $(location).attr('href', '{/literal}{$paypal_confirmation}{literal}');
        });

        // old jQuery compatibility
        $('#cgv').click(function() {
            if ($('#cgv:checked').length != 0)
                $(location).attr('href', '{/literal}{$paypal_confirmation}{literal}');
        });

    {/literal}
    {else if isset($paypal_order_opc)}
    {literal}

        $('#cgv').live('click', function() {
            if ($('#cgv:checked').length != 0)
                checkOrder();
        });

        // old jQuery compatibility
        $('#cgv').click(function() {
            if ($('#cgv:checked').length != 0)
                checkOrder();
        });

    {/literal}
    {/if}
    {literal}

    var modulePath = 'modules/paypal';
    var subFolder = '/integral_evolution';
    var fullPath = baseDir + modulePath + subFolder;
    var confirmTimer = false;

    if ($('form[target="hss_iframe"]').length == 0) {
        if ($('select[name^="group_"]').length > 0)
            displayExpressCheckoutShortcut();
        return false;
    } else {
        checkOrder();
    }

    function checkOrder() {
        confirmTimer = setInterval(getOrdersCount, 1000);
    }

    {/literal}{if isset($id_cart)}{literal}
    function getOrdersCount() {
        $.get(
            fullPath + '/confirm.php',
            { id_cart: '{/literal}{$id_cart}{literal}' },
            function (data) {
                if ((typeof(data) != 'undefined') && (data > 0)) {
                    clearInterval(confirmTimer);
                    window.location.replace(fullPath + '/submit.php?id_cart={/literal}{$id_cart}{literal}');
                    $('p.payment_module, p.cart_navigation').hide();
                }
            }
        );
    }
    {/literal}{/if}{literal}
});

{/literal}
编辑:也找到了HTML的某些部分,认为在那里很容易做到,但实际上似乎不起作用。也许是因为空(0)


这是一些JavaScript,如果网站是“iframe”,它会将用户从iframe重定向到网站:

<script>if (top !== self) top.location.href = self.location.href;</script>
if(top!==self)top.location.href=self.location.href;

我没有看到表单的部分代码,但由于您使用的是submit(),因此可以将表单的目标设置为_top:

<form target="_top" action="yoururl.php" id="paypal_payment_form">

然后,一旦您使用submit,它将打断框架并继续进入新页面

<a href="#" onclick="$('#paypal_payment_form').submit();" id="paypal_process_payment" mod='paypal'>


谢谢!然而,我认为我的措辞有误。也编辑了我的原始帖子:网站加载在iframe中,但是iframe中有一个链接,我想在用户单击它时将其带出iframe,返回到iframe下面的主窗口。您可以通过修改上面的JavaScript来完成,或者查看锚定标记的目标属性:谢谢Stephen!我尝试将其应用于HTML A标记,但没有成功。当我删除空白(0)并使其成为“常规”链接时,它起了作用。有没有可能帮助我如何将其应用于上面的JavaScript?
<a href="#" onclick="$('#paypal_payment_form').submit();" id="paypal_process_payment" mod='paypal'>