尝试删除 iframe 内的 3 个元素。负责删除元素主体 onload 上调用的元素的函数“Delete”不会运行。
<html>
<script>
<?php
echo"function delete(){
var elem0=document.getElementById('".$_GET['id']."').contentWindow.document.getElementById('".$id."');
var elem1=document.getElementById('".$_GET['id']."').contentWindow.document.getElementById('".$id1."');
var elem2=document.getElementById('".$_GET['id']."').contentWindow.document.getElementById('".$id2."');
elem0.removeChild(elem0.childNodes[0]);
elem1.removeChild(elem1.childNodes[0]);
elem2.removeChild(elem2.childNodes[0]);
}"; ?>
</script>
<body onload="delete();">
<div>
<?php
$page=$_GET['id'].".html";
$id=down;
$id1=gerar1;
$id2=gerar;
echo '<iframe src="' .$page.'" id="'.$_GET['id'].'" frameBorder="0" width="70%" height="100%" align="left" scrolling="no" />';
echo '</iframe>';
?>
</div>
<div>
<?php
echo'<iframe src="../../galeria/frame2_galeria.html" frameBorder="0" width="29%" height="600px" align="right" scrolling="yes" />
</iframe>';
?>
</div>
</body>
</html>
最佳答案
delete()
是一个关键字,这就是您的函数未被调用的原因
使用不同的函数名称而不是删除
所以它的作品......!
关于javascript - 无法使用用 php 编写的 javascript 删除 iframe 内的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50716629/