我正在尝试更改父 iframe 中以下 div 中的文本。
(我在 iframe 中运行代码)
<div class="hello1">I want to change this</div>
我怎么能做到这一点?
我试过了:
$("body #hello1", top.document).text("HELLO");
但我得到这个错误:
不安全的 JavaScript 尝试访问框架
有任何想法吗?
我正在尝试更改父 iframe 中以下 div 中的文本。
(我在 iframe 中运行代码)
<div class="hello1">I want to change this</div>
我怎么能做到这一点?
我试过了:
$("body #hello1", top.document).text("HELLO");
但我得到这个错误:
不安全的 JavaScript 尝试访问框架
有任何想法吗?
div 有一个 hello1 类,您编写的代码试图访问 id hello1。改成这个——
$(".hello1", top.document).text("HELLO");
当您需要在 iframe 中触发 click 事件并且用户已测试提交按钮时需要更改父框架边框文本时,我还使用了以下解决方案:
<script>
$("button").click(function(){
if ($('.email').val() !== 'Enter Your Best Email'){
$('.x_out', top.document).text('<< Back to the main page');
}
});
</script>
测试提交按钮一次后,会提示用户“!请填写此字段”的工具提示提示。通过 HTML5 onclick="validate();"
在第二次测试提交按钮时,包围 iframe 的边框在关闭链接中具有文本更改以引导它们返回主页面(即关闭链接关闭 iframe 并单击 iframe 中的按钮会更改父项中的此文本框架)。