Javascript post back of parent page from child page - javascript

On Button Click I am calling this JavaScript Method from Child(aspx) page.
function closechildwindow() {
window.opener.document.forms(0).submit();
self.close();
}
Its closes the child Page and its also makes a post back on the parent page. But the parent page is open in a separate Tab.
I don't want this. I want that post back to happen on parent page in same tab that is already open, and should not open in new tab.
Please help me

What you need is calling the __doPostBack() Javascript function on the parent window:
window.opener.__doPostBack();

Related

How to refresh the one browser window from another?

I am creating an application in which
There is datalist for items which contains collapsible panels with edit and delete button in the header panel.
On click of edit button I opened a new browser window for edit details using window.open(); javascript, which contains item details of the respective item and save button.
So I need functionality like when user clicks on save button on edit window, edit window should get closed and the parent page which has datalist should get refreshed. Note: Please consider I have URL of parent page.
For Closing the window I have tried following code:
string closeScript = "<script type='text/javascript' language='javascript'>window.close();</script>";
ClientScript.RegisterClientScriptBlock(typeof(CmsManagementPage),
"cancelScript",
closeScript);
But the edit window is not closed, and is there any solution for refreshing the parent page?
You can create the following function in javascript and call on edit button:
function editClose(url) {
window.opener.location=url;
window.close();
}

Call Javascript function on iFrame reload

So I have the following problem: I have a website in an iFrame. I want the parent site to scroll up to the top once you go to a new page inside the iFrame, which it does via this JavaScript:
function scrollToTop() {
if ('parentIFrame' in window) {
window.parentIFrame.scrollTo(0,0);
return false;
}
}
But, on one page I have a two-part form. If you submit the first form, you get to the second one, but both parts are in the same PHP document, so you stay on the same page, but the iFrame is reloaded. I want the page to scroll to the top once you submit the first form, but the above JavaScript doesn't seem to work. Can anyone help? Would be much appreciated!
use iframe onload event that will get triggered, once frame loads content,
onload="myFunction()"
During the first form submissiom submit the page through Ajax call back method

In ASP.NET, how can a child window keep track of parent?

I have an application that produces many pages of content. In order to expedite review of the process, I have a linkbutton that opens a child window starting at the page I'm on so reviewers can enter comments. I open the child window in javascript
objCmtWindow = window.open(MyURL, "comments", "width=800,height=600,menubar=no,toolbar=no,status=no,location=no,resizable=yes,scrollbars=yes,directories=no");
objCmtWindow.focus();
The child window has some javascript (an excerpt from a larger script) to listen to an API in the parent window so that it can know what to load
function updtSlide(){
if(window.opener.MyAPI)
{
window.opener.MyAPI.addEventListener("MyEnterBtn", function(e)
{
updtContent();
});
}
}
It works on load to grab the data with the function updtContent as part of the page load. When I click for the next page (MyEnterBtn) in the parent window, the child window is not updating for the next page data it needs to display. Is there a piece I'm missing to poll the parent window? Since the parent can operate independantly of the child, I really can't put the command in the next page button. I know the API is working correctly and emitting next page events.
Thank You
In the js function, the first 'opener' is spelled wrong.

Parent Jsp page refresh when click on popupwindow alert box

I am working on jsp's, I have two jsp one in configDb.jsp, in that I have written code to retrieve the values from database and display it. In this whereas I have option like newconnection.. its a popup window. When I click on that it opens popupwindow and taken the values and store them in a database, but in my parent page I am not able to display those values. After I click on the ok button in popup window, I have to refresh the parent page, then I am able to see the values which I have created few seconds back by the new connection page. Could anyone please help me out?
You can include this in your HTML for the popup window.
<script type="text/javascript">
function proceed(){
opener.location.reload(true);
self.close();
}
</script>
<form onsubmit="proceed()">
...
</form>
Actually you can obtain the answer by googling "javascript refresh parent page from popup" and you will see stackoverflow's answer :)
A better alternative without the need of refreshing the parent page can be achieved by adding a submit button listener and perform a DOM action to insert the new element with new content. This can be easily done by Javascript.

Does Parent window (The first page of my site) gets focus when closing childs till i return to it?

In my system I have a main page, that when clicking on any element on that page a new page is opened, in some cases (button click on child page) from the child page will be open a new page, and so on... when I decide to close any child I need to close all levels to the top and refresh the top level page because on the child level I'm doing Database manipulations and I need to see them when I am returning to the main page.
Every thing is working great, the only problem is with the refresh of the first page!
I've tried doing onunload... in the last child...and I've tried JQuery focus for the page itself....
Any one have any idea please?
Some code:
1) this is in the top parent page:
$(document).live(
'focus',
function()
{
window.location.reload(true);
}
);
2) this is in the last child (the one that the top parent page calls):
<body class="RTL" onunload = "opener.close()">
And I've tried many variations of that....
If any one have any idea it will help a lot, because as for now I need to do Setinterval() and refresh the main page all the time and this is really not nice....
Consider using iframes to show the child pages. That way, the child can use window.parent.reload() to reload the page.
If that is not possible: Did you check that opener actually contains the correct window? It might be the second-last child instead.

Categories

Resources