Skip to content

Instantly share code, notes, and snippets.

@stephennancekivell
Created September 1, 2012 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephennancekivell/3566315 to your computer and use it in GitHub Desktop.
Save stephennancekivell/3566315 to your computer and use it in GitHub Desktop.
controlling iframes with javascript
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery-1.8.0.min.js"></script>
</head>
<body>
<script type="text/javascript">
function doCall(){
$.get('foo').error(function(){
parent.afterCall();
});
}
</script>
</body>
</html>
<html>
<body>
<script type="text/javascript">
function afterCall(){
console.log('afterCall');
}
</script>
<iframe id="doCallFrame" src="./frame.html"></iframe>
<button onclick="document.getElementById('doCallFrame').contentWindow.doCall();">click me</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment