javascript - IFrame get parameters from parent url on different domain -
it seems not possible default because error blocked frame origin x accessing frame origin y. know because of security allow partners integrate iframe. iframe on domain mysubdomain.mysite.com , contains search box. once user has made search has been redirected page partners-domain-containing-search-results.com search results on domain mysubdomain.mysite.com , read parameters url (hash , query string parameters) can't because can't read parent url parameters (from partners-domain-containing-search-results.com ).
you should able use top.location
subdomain.mysite.com read parent urls of partners-domain-containing-search-results.com:
e.g. iframe hosted on mysubdomain.mysite.com , embedded in partners-domain-containing-search-results.com?hello=true#blabla should able run:
top.location.hash >"#blabla" top.location.search >"?hello=true"
note: cannot modify other domain's location object or see:
uncaught securityerror: blocked frame origin "http://domain2.com" accessing frame origin "http://domain.com". protocols, domains, , ports must match.
Comments
Post a Comment