I use a popup window for edit operations using the Kendoui framework.
When a session times out while the popup is open the login page will load inside of the popup window.
I would like to add js in the forms redirect page and check if it is being loaded inside a popup window and if so redirect and close the window.
Is there a way to determine if a page is loaded inside of a popup and if so how can I get a handle to it?
Thanks
Usually the page is not redirected to the login page until you click button or do something.
We had the same problem and we solved it using Ajax call for our popup.
So we had some button on the popup and we read the response from the server. If the session is already expired you will have the wrong response code (not 200 definitely). You can read and interpret it and in your JS close popup window and do redirect to the login page like:
window.location = login_url
Related
Lets say I have a javascript popup window (opened using var popup = window.open()), that is pointing to the same domain.
How can I detect each time a page is loaded from the page that opened the popup (eg. after a link is clicked on or a form is submitted) o I can check if the user performed an action? Bonus points if I can get the url and response code for the page (that is loaded in the popup).
I'd also like to note I would not like to rely on the loaded page within the popup to provide information (by firing events).
I am currently working on a project where i can open a child window anywhere within the site, to display order details relating to the logged in user. On one of the pages i need to refresh the data when the window is closed. I have worked out how to refresh the data if the window is closed and the window was opened on that page. The issue i am having is if the child window was opened on a different page and the user navigated to the page that requires it to refresh once the window is shut, i need to obtain the reference to the open child window so i can call my javascript that causes the data to refresh, if the child window is shut.
First its seen little bit tricky..
you declare some ajax function to send information to server whether child window opened or not.. if child window opened then refresh page.
for E.g .
-> assume that user opened 2 same page In different tabs1 and tab2.
-> user opened opened popup window on tab2 and add/change some information..
-> tab2 content refresh as per ur event.
you should also send a one flag to server with session id and tab1 continuous check is that any changes happed to server it will be refresh..
I was able to solve the issue i was having using the code from the following link
Obtain reference to existing browser window
You can open child window with javascript like this.
window.open("ChildWindowURL.aspx?source=windowA");
In the Page_Load of child, you can get the source.
string action = Request.QueryString["source"];
You can send this value to client side with hidden value, and when child window is closed, do refresh or what you need.
Hey I am trying to open a popup in a page and access the DOM in the opened popup from JavaScript in opener page. However I was unable to do so.
I am doing
myWindow=window.open(url,'','width=200,height=100');
then trying to access body of the popup as
myWindow.document.body
I am getting undefined for that.
Note the popup being opened is in another server from the opener page.
Is it me doing something wrong or is it impossible to do so?
I have a question on javascript window management.
My application opens an iframe which displays a link. Clicking on the link, opens a popup window, in which I enter my login credentials. My intention is to close the popup window after the login credentials are entered. And this I have been able to achieve using a JS call to self.close().
There after my server side script does some more processing and would like to display the results back in the iframe. This is where things break for me.
The overall flow is as follows:
Iframe Displays a Link --> Clicking on the Link Pops up a window --> Popup Window closes after credentials are entered --> I see my original iframe now (How do I display the contents back in the iframe). Here is the code snippet that closes the popup.
5
6 self.close();
7
The parent of the popup is the iframe. If I modify the above script to give the focus back to its parent, which in my case will be the iframe, will that suffice? Or am I issing something here?
you can access the iframe from your popup by using opener. for example this will reload your iframe:
<script type="text/javascript">
opener.location.href = "htp://mypage.com/myiframe.php";
</script>
you just have to add the right parameters to show what you want to. (of course you have to do this before your self.close();)
I'm using the jQuery-UI dialog widget in a Grails-based application to load a remote page (in this case, a simple file upload form). The remote page is defined elsewhere in my project, and doesn't know it is being loaded in a dialog.
Is there any way to close the dialog via a link in the remote page? Would I have to somehow pass a reference to the dialog when I load the page, or is there a way to trigger the close event while remaining agnostic of the dialog itself?
Try this HTML:
CLOSE
and this JavaScript:
$("#btnDone").click(function (e) {
e.preventDefault();
var dialogDiv = $("#btnDone").parents(".ui-dialog-content");
if (dialogDiv.length > 0) {
dialogDiv.dialog('close');
}
});
in your remote page. It will look to see if it is inside a dialog and if so, it will close it. If not, it will do nothing.
If you give your dialog a known ID then you can look it up using jquery (e.g. $('#mydialog') and close it via script on the remote page. The only issue might be getting JS to be evaluated when the remote page is loaded into the dialog.