[英]PHP echo in Javascript
I have this code: 我有以下代码:
document.getElementById('root').style.left = '<?php echo $page_position[$info["os"]][$info["browser"]][0]; ?>';
document.getElementById('root').style.top = '<?php echo $page_position[$info["os"]][$info["browser"]][1]; ?>';
Why won't this work like this? 为什么这样不行呢?
Can anybody point me in the right direction? 有人能指出我正确的方向吗?
EDIT: 编辑:
<?php echo $page_position[$info["os"]][$info["browser"]][1]; ?>
echoed "top:300px;" 回显“ top:300px;”
Sorry guys, very stupid error of mine :/ 抱歉,我的愚蠢错误:/
如果将其放在.js
文件中,则它将无法工作,因为它必须位于为PHP( .php
)解析的页面中。
print_r($info)
will help you out. print_r($info)
将帮助您。 root
element exists. root
元素存在。 Again, use your console. My money goes on #3, you probably have a JavaScript error somewhere that is stopping execution of the script. 我的钱花在了#3上,您可能在某个JavaScript错误中停止了脚本的执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.