Javascript 如果在父页面的iframe中找到元素ID,请执行某些操作

Javascript 如果在父页面的iframe中找到元素ID,请执行某些操作,javascript,iframe,Javascript,Iframe,我在同一个域的父页面中有一个iframe。我需要在iframe中找到ID“applications”时触发父页面中的更改。 这个javascript函数正确吗 function load(){ if (window.frames[0].document.getElementById('applications')) { var str=document.getElementById("tst").innerHTML; var n=str.replace("Login","Delogare");

我在同一个域的父页面中有一个iframe。我需要在iframe中找到ID“applications”时触发父页面中的更改。 这个javascript函数正确吗

function load(){
if (window.frames[0].document.getElementById('applications'))
{
var str=document.getElementById("tst").innerHTML;
var n=str.replace("Login","Delogare");
document.getElementById("tst").innerHTML=n;
document.getElementById('tst').title ='logout';
document.getElementById('tst').href='logout';
document.getElementById('prt').href='../profil/cont.html?refresh';
}}

谁能说呢?很特别,功能看起来不错。使用iframe onload执行寄存器加载功能