【问题标题】:Pass through '&parameter' in a URL通过 URL 中的“&parameter”
【发布时间】:2013-07-20 23:35:18
【问题描述】:

我正在开发一个项目,该项目使用以下代码将变量传递到 iFrame:

jQuery(function() {
    var search = window.location.search;
    jQuery(".iframe-wrapper").attr("src", jQuery(".iframe-wrapper").attr("src")+search);
});

但是,当我在 URL 中通过 &section=P1 时,它只会给出 404。

iFrame 来源:example.com/page?cart=1

转到site.com/&section=P1 后,iFrame 应更改为example.com/page?cart=1&section=P1

无论如何要通过URL 传递&section=P1

【问题讨论】:

    标签: wordpress iframe parameters url-parameters


    【解决方案1】:

    请发送您的 HTML,因为我的 HTML 可以正常使用以下内容:

      <iframe width="500" height="200" class="iframe-wrapper" src="http://www.google.com?param=1"></iframe>
        <script type="text/javascript">
         $(function() {
        var search = window.location.search;
        search = search.replace("?","&");
    
        $(".iframe-wrapper").attr("src", $(".iframe-wrapper").attr("src")+search);
        });
        </script>
    

    【讨论】:

    • 如我所说,iFrame SRC上面已经有参数了,这就是问题所在,我只想在URL中加上&amp;section=P1
    猜你喜欢
    • 2011-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-24
    • 2023-02-08
    • 2019-05-06
    • 2013-11-10
    • 2015-07-30
    相关资源
    最近更新 更多