html - Javascript - checking if frame is empty -
i tried check if frame "content1" , "content3" empty or not , resizing them.
but size changes every loop
window.setinterval(function () { check(); }, 50); function check() { var content1 = document.getelementsbyname("content")[0].contentdocument.body; var content3 = document.getelementsbyname("content3")[0].contentdocument.body; if (isempty(content3)) { if (isempty(content1)) setproperties("0px, *, 0px"); else setproperties("35%, *, 0px"); } else setproperties("25%, 40%, 35%"); window.localstorage.clear(); } function isempty(e) { return (e.offsetwidth != 0); } function setproperties(value) { document.getelementsbytagname("frameset")[1].cols = value; }
well, error means says: e
null
, e.offsetwidth
throw exception. check e
also:
return !!(e && (e.offsetwidth != 0 || e.innerhtml != "\n"));
the !!
makes such function returns boolean true
or false
result, isn't necessary isfoo()
functions nice.
why e
null? in case it'd because code didn't find either "content" or "content3" elements on page.
Comments
Post a Comment