javascript - How to make chrome/firefox able to run parent.frame -
i working on old web not supporting chrome/firefox. 1 problem code can run on ie not chrome/firefox.
put 'parent.frames("snscont").location.href="../../../../../fts/main/account/initial.html"';
on chrome,it indicated uncaught type error: parent.frame not function. jquery or modern code can make supported chrome/firefox? lot.
you can use following code fallback parent.frames
old ie behavior:
function isfunction(obj) { return !!(obj && obj.constructor && obj.call && obj.apply); } if (parent.frames && !isfunction(parent.frames)) { var originparentframes = parent.frames; parent.frames = function(name) { return originparentframes[name]; }; }
for questions in comment:
why use parent?
without context of code, it's hard answer question. basically, parent
references parent of current window or subframe, if invoked on window not have parent, references itself. can check https://developer.mozilla.org/en-us/docs/web/api/window/parent more detail (thanks @jeetendra's answer).
i guess code run in iframe? if true, parent.frames(b)
in frame a
way reference iframe b iframe a.
is parent object?
yes, parent
object attached on window
. can run typeof parent
result object
.
what snscont? parameter function frames()?
snscont
name of iframe. parent.frames()
use name reference iframe object. so, yes, passed parameter.
what latter part starting form href means? redirecting page listed @ end?
yes, ...location.href="..."
statement makes iframe display url. don't think redirect
accurate word here.
Comments
Post a Comment