From a child document of different origin you are not allowed access to the top window's location.hash
property, but you are allowed to set the location
property itself.
This means that given that the top windows location is http://example.com/page/
, instead of doing
parent.location.hash = "#foobar";
you do need to know the parents location and do
parent.location = "http://example.com/page/#foobar";
Since the resource is not navigated this will work as expected, only changing the hash part of the url.
If you are using this for cross-domain communication, then I would recommend using easyXDM instead.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…