dz代码编辑器,插入页面代码GPT优化版
dz代码编辑器,插入页面代码GTP优化版<iframe id="myFrame" src="{1}" style="width: 1500px; height: 1200px; border: none;"></iframe>
<script>
(function() {
const iframe = document.getElementById('myFrame');
iframe.onload = function() {
try {
const iframeDocument = iframe.contentWindow.document;
// 阻止 iframe 内部的超链接点击事件
iframeDocument.addEventListener('click', function(e) {
const link = e.target.closest('a');
if (link) {
e.preventDefault();
console.log('Link click blocked:', link.href);
}
}, true);
// 阻止 iframe 内部的表单提交事件
iframeDocument.addEventListener('submit', function(e) {
e.preventDefault();
console.log('Form submission blocked');
}, true);
} catch (error) {
console.error('无法访问 iframe 内容,可能是跨域问题:', error);
}
};
})();
</script>
页:
[1]