Skip navigation
Coubilias
Currently Being Moderated

SandBoxe Bridge in Multi iFrames

Jan 3, 2013 8:14 AM

Tags: #bridge #multi #iframes #sandboxe

Using sandbox bridge between the parent html file like

 

<script>

var bridgeInterface = {};

bridgeInterface.testProperty = "Bridge engaged";

bridgeInterface.testFunction = function (getMe){

alert(getMe);

};

 

function engageBridge(){

    document.getElementById("mainFrame").contentWindow.parentSandboxBridg e = bridgeInterface;

}

</script>

 

<iframe sandboxRoot="http://localhost/" documentRoot="app-resource:/" allowCrossDomainXHR="true"  ondominitialize="engageBridge()" name="mainFrame" ></iframe>

 

 

 

and the call of it from within the iframe page like

 

 

 

<script>

function tryMe(){

alert(window.parentSandboxBridge.testProperty);

window.parentSandboxBridge.testFunction('coub2');

}

</script>

 

<a  href="#" onClick="tryMe(); ">Link!</a>

 

 

works like a charm.

 

Any ideas how to access the bridge when a second iframe is loaded within the first iframe ?

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points