javascript - Can the default `window.top` ever be invalid as a reference? -


i want redirect user external page , simultaneously break out of frameset.

the outermost frameset within same domain page doing redirection, there possibility span domains. in development, outermost frameset might not exist @ all. ideally, want cover situations.

the innermost page (the 1 has breakout code) going served on https. target url may http or https. acceptable redirection fail (there fallback link "click here continue" cover scenario) redirection should work in majority of cases. particularly purposes of question, i'd hate more browser-dependent necessary.

the web application asp.net.

because of framesets, can't use http redirect.

so far have javascript code, registered startup script within class subclassing page, ... represents redirection target url:

((window.top == null) ? (window) : (window.top)).location = '...'; 

what bothers me mdn has window.top , window.parent, respectively. particularly, documentation window.parent spells out explicitly that

if window not have parent, parent property reference itself.

which means can assert window.parent != null. there nothing similar value of window.top.

for purposes of question, can assume neither of these have been reassigned.

all lead actual question: does window.top make guarantees similar of window.parent? (i'm bit concerned conditional expression. in far limited testing works, doesn't prove correct.)

as far can tell, @ least mdn doesn't either way.

the html5 spec defines window.top so:

the top idl attribute on window object of document in browsing context b must return windowproxy object of top-level browsing context (which own windowproxy object if top-level browsing context itself), if has one, or own windowproxy object otherwise (e.g. if detached nested browsing context).

so top attribute must refer window. spec defines top readonly not posisble change point else (if spec implemented properly).

something bad if window.top == null!


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -