Friday, 13 September 2013

Update parent from iframe using jquery

Update parent from iframe using jquery

I have this minimal test case
a.html
<!DOCTYPE html>
<html>
<body>
<input type="text" id="myinput">
<iframe id="frame" src="b.html" style="width:100%;height:100%"
frameBorder="0"></iframe>
</body>
</html>
b.html
<!DOCTYPE html>
<html>
<body>
<script>
function update_parent(value) {
window.parent.document.getElementById('myinput').value=value;
}
</script>
<a class="tag" name="something" href="javascript:void(0)"
onclick="update_parent(something)"/>Bla Bla</a>
</body>
</html>
The purpose here is to update the input box in parent window, when a
button is clicked on the iframe. I tried to do it using plain javascript
as you can see above, but it doesn't work either. I want to do this using
jquery if possible.

No comments:

Post a Comment