gpt4 book ai didi

php - Wordpress 函数在 wordpress 的 iframe 中不起作用

转载 作者:行者123 更新时间:2023-11-28 11:01:04 26 4
gpt4 key购买 nike

我在wordpress中使用iframe,但是iframe中的页面不支持wordpress功能。iframe 中的页面来自同一域。

这是我正在尝试做的事情: 我正在尝试通过 wordpress 函数在 iframe 页面内调用 css。以下是我如何使用 iframe 标签:

<iframe id="iframeBox" src="<?php echo get_template_directory_uri();?>/iframe/scoreboard_summary.php" sandbox="" FRAMEBORDER="no" ></iframe>

这是我页面 scoreboard_summary.php 中的 css 调用标签:

<link type="text/css" rel="stylesheet" href="<?php echo get_template_directory_uri();?>/style.css">

函数 get_template_directory_uri() 不工作?

请告诉我我需要做什么?提前致谢。

最佳答案

iframe 只是拉入并显示在 div 中的网页。你不能以那种方式与他们互动。 PHP 已经吐出了你设置的循环和规则所定义的内容。如果您想与服务器对话并每隔一定时间调出新数据并跳过 iframe,您可能需要查看 ajax 以获取类似的东西。

<?php echo 'do this thing' ?>就变成了this thing页面加载后。没什么可 Hook 的。

如果您只是想获取样式表并将其应用于您的页面,那么我建议获取该样式表的完整标准 URL 并跳过模板目录 uri 等。

也许你可以用一些代码或像这样的例子更好地解释它,它是一个按时间间隔刷新的 iframe。祝你好运!

http://jsfiddle.net/sheriffderek/3C9qP/

关于php - Wordpress 函数在 wordpress 的 iframe 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22432953/

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