I have a modal window which closes when i add an item. The parent page will refresh once the modal window is closed. But i don't want the whole window to get closed, but i want a particular div to get refreshed. is there any javascript way to do it ?
You can call a javascript method in the parent window while closing the child window. This is very simple.
You can have a javascript method to refresh the content of the div
<script language=”javascript” type=”text/javascript”>
function ParentWindowFunction()
{
alert(‘Need to refresh targetdiv. I am instructed from child window’);
//refresh the div
return false;
}
</script>
And in the child window, you may have some button to close that window and also can call up the parent window's javascript
<script language=”javascript” type=”text/javascript”>
function CallParentWindowFunction()
{
window.opener.ParentWindowFunction();
return false;
}
</script>
<input type=”button” name=”btn1″ value=”Call Parent Window Function” onclick=”javascript:return CallParentWindowFunction();”/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With