javascript - Why can a child redirect a parent frame? -


i have @ these 2 questions , don't understand.

redirect parent window iframe action

how prevent iframe redirecting top-level window

on 1 hand appears can redirect parent iframe , on other cannot? when try it, have no problem redirecting parent frame i'm curious in why cannot redirect parent frame unless on same domain. can redirect without having frame on same domain.

as stated previously, redirect parent iframe. 1 thing bear in mind both website, , site contained in iframe need on same domain work, or you'll access denied exception.

is browser related?

edit

i have 2 pages , works shouldn't :

on domain 1

<html>   <body>     <iframe src="http://domain2.fr"></iframe>   </body> </html> 

on domain 2

<html>   <body>     <script type="text/javascript">       window.top.location.href = "http://google.fr";     </script>   </body> </html> 

the answer why possible simple. window.location part of web api, not same javascript core. it's part of dom interface, hence it's gouverned w3c, not ecma. that's why allows manipulate top-window's properties.

strictly speaking, js isn't capable of doing this, because lacks io capabilities, makes language extremely portable. that's why browser implementations require dom api, query dom, , request repaints or interact client. dom, though, does need io, because renders, , reads actual ui. people in ecmascript committee rather have seen access window.top heavily restricted, if not removed together, xss vulnerability reasons. sadly w3c agreed disagree, , implemented window.top reference anyway.
who's right or wrong in case? don't know, it's easy redirect client malicious site within iframe, unsafe. frustrating have iframe, , not having access top window, mean not being able interact client easily. that's not point here. bottom line is, can change top window properties, , can useful. think mashups. pose lot of challenges in terms of xss safety, open lot of new , exciting possibilities webaps. plug of dangerous xss vulnerabilities, take @ adsafe, created douglas crockford. google has similar lib, forgot name atm...

the same origin policy doesn't apply here, either. changing url in address bar in browser window, you're changing window.top.location.href property, too. if there same-origin restrictions there, internet dead. you're not sending request location, you're not getting data third-party resource , loading in page, you're redirecting browser location, closes , clears dom.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -