PHP and iframe display -


'a' site javascript alert(document.domain);

'b' site.

now problem want iframe 'a' site under 'b', whenever open 'b' site , should showme 'a' site javascript popup (document.domain) of 'a'.

here coded not working correctly, here running javascript under 'b' want run under 'a'.

<?php  $ch = curl_init();    curl_setopt_array($ch, array(      curlopt_returntransfer => 1,      curlopt_url => 'http://mysites.com/index.php',      curlopt_useragent => 'ghfhfh'  ));    $resp = curl_exec($ch);    echo $resp;  echo $_server['request_uri'];  curl_close($ch);  ?>

this code in 'b' site index.

after opening 'b' site javascript pops 'b' 's domain not 'a'.

anyone me please.

if goal share messages (like site iframe loading, or pass event site iframe parent b site), think should use post message.

with few lines of code, can create two-way communication between b site , site iframe. you'll need write simple javascript in site b reception of message, specifying site's domain of sender(origin), , simple javascript code within site (which reside inside iframe ) send message . once in javascript, can decide time send out message site a.

the postmessage technology used long various facebook, twitter, youtube , allows solve problem of cross domain.

docs: https://developer.mozilla.org/en-us/docs/web/api/window/postmessage

example: http://viget.com/extend/using-javascript-postmessage-to-talk-to-iframes

let me know if need help! ;)


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -