【发布时间】:2012-06-22 13:36:10
【问题描述】:
我已将此代码应用于 iframe id。
<iframe id='<?php echo 'fraDisabled'.$i.$post->ID; ?>' src='<?php echo $file['url']; ?>' ></iframe >
function disableContextMenu()
{
var text="you dont have proper privelages to do this !!";
window.frames['<?php echo 'fraDisabled'.$i.$post->ID; ?>'].document.oncontextmenu = function(){alert(text); return false;};
window.frames['<?php echo 'fraDisabled'.$i.$post->ID; ?>'].document.onkeypress = function(){alert(text); return false;};
window.frames['<?php echo 'fraDisabled'.$i.$post->ID; ?>'].document.onmousedown = function(){alert(text); return false;};
}
PHP:
<iframe id='<?php echo 'fraDisabled'.$i.$post->ID; ?>' src='<?php echo $file['url']; ?>'>
</iframe>
它适用于 Chrome,但不适用于 Mozilla Firefox。
【问题讨论】:
-
我认为“Mozilla”是指 Firefox。
-
你必须在
var text中转义'。 -
您确定这正是您拥有的代码吗?如果有任何浏览器接受它,我会感到惊讶。
-
@juhana 我实际上传递了 php 代码,因为 iframe id 是动态的,所以我通过循环传递了 php 代码。
-
在编辑时,是否在行首放了 4 个空格,因为这会自动将其变成“代码”块。我建议的
name属性在哪里?
标签: php javascript firefox iframe