gpt4 book ai didi

javascript - 如何在 WordPress 中的关闭/body 标签后添加 Javascript

转载 作者:行者123 更新时间:2023-11-28 05:35:06 25 4
gpt4 key购买 nike

我正在尝试将 iFrame 嵌入到几个 WordPress 页面中。每个页面都会使用不同的 iFrame 内容。这是一个商业网站,因此需要第一个 iframe 作为客户的登录。不同 WP 页面上的后续 iframe 将用于产品搜索、结帐...((我的问题在底部))

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

  2. 我在每个页面的正文中添加了 iframe。

  3. 我需要将 iframe 初始化为特定的 iframe 内容。我想将此代码放在结束后 </body>标签如下:

<小时/>
 <html>
<head>
<script>
var absDomain = "http://www.webstore.com/"
var iframeObj;
var timestampString = '' + new Date().getTime() + ''
document.write('<script type="text/javascript" src="' + absDomain + 'Support.js?'+timestampString+'"><\/script>');
document.write('<script type="text/javascript" src="' + absDomain + 'ProductSearch.js?'+timestampString+'"><\/script>');
document.write('<script type="text/javascript" src="' + absDomain + 'Environment.js?'+timestampString+'"><\/script>');
function gotoIframe(theLocation){
var timeStamp = "";
iframeObj = document.getElementById("iframeContent");
timeStamp = "&" + new Date().getTime();
iframeObj.src = absDomain + theLocation + "?iframe=yes" + timeStamp;
}
function executeIFrameProductSearch(str1, str2){
goTo_CategoryForIframe(str1, str2, document.getElementById("iframeContent"));
}
</script>
</head>
<body>
<!-- iFrame embedded below -->
<iframe id="iframeContent" style="width:100%;height:500px; " src=""></iframe>
</body>
<script>
//script needed for initial iframe page and iframe support.
iframeObj = document.getElementById("iframeContent");
gotoIframe("CustomerLogin.html");
</script>
</html>
//After the above code section (after the </body> tag) is embedded into the Login page, I expect to use:
//Customer Login:
<a href="javascript:gotoIframe('CustomerLogin.html')">Customer Login</a>
//Product Search:
<a href="javascript:gotoIframe('ProductSearch.html')">Product Search</a>

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

最佳答案

将 script 标签放在 body 标签后面是无效的,但如果你确实想这样做,你可以查看主题的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>

关于javascript - 如何在 WordPress 中的关闭/body 标签后添加 Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39421505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com