Scenario:
domain1.com hosts an iFrame of domain2.com.
domain2.com is using javascript to trigger dynamic links that need to route to the parent window.
The links are all relative paths.
Clicking on /linkA.html (in iframe on domain2.com) routes the parent to domain1.com/linkA.html.
var _generic = "/linkA.html";
$("#canvas").each( function () { $(this).children("a").attr("href",_generic); $(this).click( function(e) { e.preventDefault(); window.parent.location.href = _generic; } ); } );
Changing the links to absolute (domain2.com/linkA.html) solves the functional problem.
Has anyone run into this before?
In order for the browser to resolve the entire url when setting relative paths, it first needs to read the current href, and this is blocked by the SOP.
But I am pretty sure that if you use
parent.location
instead ofparent.location.href
, then this will work just fine.