如何在WordPress中关闭/body标记后添加Javascript

如何在WordPress中关闭/body标记后添加Javascript,javascript,php,html,wordpress,iframe,Javascript,Php,Html,Wordpress,Iframe,我试图在几个WordPress页面中嵌入一个iFrame。每个页面将使用不同的iFrame内容。这是一个商业网站,所以需要第一个iframe作为客户的登录名。不同WP页面上的后续iFrame将用于产品搜索、签出。。。((我的问题在下面) 在header.php中,我放置了一些需要包含在每个WordPress页面上的初始代码 我在每个页面的正文中添加了iframe 我需要将iframe初始化为特定的iframe内容。我想将此代码放在关闭标记后,如下所示: var absDomain=”http

我试图在几个WordPress页面中嵌入一个iFrame。每个页面将使用不同的iFrame内容。这是一个商业网站,所以需要第一个iframe作为客户的登录名。不同WP页面上的后续iFrame将用于产品搜索、签出。。。((我的问题在下面)

  • 在header.php中,我放置了一些需要包含在每个WordPress页面上的初始代码

  • 我在每个页面的正文中添加了iframe

  • 我需要将iframe初始化为特定的iframe内容。我想将此代码放在关闭标记后,如下所示:


  • 
    var absDomain=”http://www.webstore.com/"
    var iframeObj;
    var timestampString=''+新日期().getTime()+''
    文件。写(“”);
    文件。写(“”);
    文件。写(“”);
    函数gotoIframe(位置){
    var timeStamp=“”;
    iframeObj=document.getElementById(“iframeContent”);
    timeStamp=“&”+新日期().getTime();
    iframeObj.src=absDomain+位置+“?iframe=yes”+时间戳;
    }
    函数ExecuteFrameProductSearch(str1、str2){
    goTo_CategoryForIframe(str1、str2、document.getElementById(“iframeContent”);
    }
    //初始iframe页面和iframe支持所需的脚本。
    iframeObj=document.getElementById(“iframeContent”);
    gotoIframe(“CustomerLogin.html”);
    //在将上述代码部分(标记后)嵌入登录页面后,我希望使用:
    //客户登录:
    //产品搜索:
    

    问题:我应该在哪里插入每个特定WordPress页面的结束标记后面的代码?谢谢。

    将脚本标记放在正文标记之后是无效的,但是如果您确实想这样做, 您可以查看主题的footer.php

    例如,您可以在footer.php中找到如下代码:

    <?php
        </div><!-- close tag for content container -->
    ?>
        <footer>
        <!-- footer content -->
        </footer>
        </body>
        <!-- here is the place to put your code -->
    </html>
    

    将脚本标记放在正文标记之后是无效的,但如果您确实想这样做, 您可以查看主题的footer.php

    例如,您可以在footer.php中找到如下代码:

    <?php
        </div><!-- close tag for content container -->
    ?>
        <footer>
        <!-- footer content -->
        </footer>
        </body>
        <!-- here is the place to put your code -->
    </html>
    

    将此函数复制并粘贴到functions.php文件中

           //alert(); enable alert to test
              //script needed for initial iframe page and iframe support.`function your_function() {
    echo '<script>`
              iframeObj = document.getElementById("iframeContent");
              gotoIframe("CustomerLogin.html");
    
         </script>';
    
    //警报();启用警报以进行测试
    //初始iframe页面和iframe支持所需的脚本。`function your_function(){
    回声'`
    iframeObj=document.getElementById(“iframeContent”);
    gotoIframe(“CustomerLogin.html”);
    ';
    
    }

    添加动作('wp_footer','your_function',100);//这将在每个页面的body标记之后添加脚本

    其他选择将是 //在这一行以上或任何地方

    函数前缀\u脚本\u打开\u正文\u标记()后{ $javascript=file_get_contents(get_template_directory()。/js/opening body.js'); 回显“.$javascript.”; }

    添加动作('yourprefix'u在'u opening'u body'u标记之后,'yourprefix'u scripts'u在'u opening'u body'u标记之后)'


    将此代码粘贴到footer.php中,在其中显示

    将此函数复制并粘贴到functions.php文件中

           //alert(); enable alert to test
              //script needed for initial iframe page and iframe support.`function your_function() {
    echo '<script>`
              iframeObj = document.getElementById("iframeContent");
              gotoIframe("CustomerLogin.html");
    
         </script>';
    
    //警报();启用警报以进行测试
    //初始iframe页面和iframe支持所需的脚本。`function your_function(){
    回声'`
    iframeObj=document.getElementById(“iframeContent”);
    gotoIframe(“CustomerLogin.html”);
    ';
    
    }

    添加动作('wp_footer','your_function',100);//这将在每个页面的body标记之后添加脚本

    其他选择将是 //在这一行以上或任何地方

    函数前缀\u脚本\u打开\u正文\u标记()后{ $javascript=file_get_contents(get_template_directory()。/js/opening body.js'); 回显“.$javascript.”; }

    添加动作('yourprefix'u在'u opening'u body'u标记之后,'yourprefix'u scripts'u在'u opening'u body'u标记之后)'


    将此代码粘贴到footer.php中,您希望在其中显示

    Thank you@ucheng。这就是我想要的。欢迎你@Petr,请投赞成票或接受答案。非常感谢。谢谢你@ucheng。这就是我想要的。欢迎你@Petr,请投赞成票或接受答案。非常感谢。我不需要在结束标记后添加任何东西。你能详细解释一下吗?我没有奇怪的要求在结束标签后面放任何东西。你能详细说明一下吗?