Jump to content

Recommended Posts

From my parent window I open up a child window. What I want to do is run something in the child window, then onces it competes. Update a div tag in the parent then close the child window.

 

this is my JS in the child window

function update_parent(){
window.opener.document.getElementById('resultDIV').innerHTML = 'Here I am';
}

 

When I test this, I get an access denied JS error. Any ideas on what I should do or change? Thanks

Link to comment
https://forums.phpfreaks.com/topic/214191-updating-parent-window/
Share on other sites

Works fine for me. Must be a problem somewhere else in your code. Here is the code I tested with

 

Parent

<html>
<body>

<button onclick="window.open('child.htm')">Open Child</button>

<div id="resultDIV">Doesn't work</div>

</body>
</html>

 

Child

<html>
<head>

<script type="text/javascript">

function update_parent()
{
  window.opener.document.getElementById('resultDIV').innerHTML = 'works';
  window.close();
}

</script>

</head>
<body>
<button onclick="update_parent()">Update Parent</button>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.