PHP+Javascript如何正确放置iframe

PHP + Javascript how to place iframe correctly

本文关键字:iframe 何正确 PHP+Javascript      更新时间:2023-09-26

如何在PHP中使用javascript正确放置iframe?我尝试了下面的代码,但只收到空的iframe。

<html>
<head>
</head>
<body>
<?php
echo '<script  type="text/javascript">
i = document.createElement("iframe");
i.setAttribute("src", "http://google.com");
document.body.appendChild(i);
</script>';
?>
</body>
</html>

实际上,您的代码运行良好,不需要额外的更改。

唯一的问题是google.com不允许您在iframe上调用它。试试你的域名,它肯定会起作用。