I have child window which has a hyperlink. On click of hyperlink i have to redirect to parent window. I could do this using following syntax-
<a target="main" href='${pageContext.request.contextPath}/xyz/abc.jsp?id=123'/>
Suppose i have two parent window (P1 and P2) with two different session (S1 and S2 respectively) open. If i try to open child window from P2 and click on hyperlink, it redirects to P1 window. This behavior is very inconsistent. How can i ensure that hyperlink on each child window updates to their respective parent window ?
Related
I have my web app with two popup windows parent and child
Sometimes the child popup can be opened directly from the main application
when user open the child popup from the parent popup, I would like to close the parent popup (if the child was called from the main application then close nothing)
So the parent code to open the child popup looks like so:
the window.open then window.close(); to close the parent
The reason my code is in a table on click because its a fancy button.
<TABLE id="openChild" class="clsButton" cellpadding=0 cellspacing=0 width="31px"
onclick="window.open('www.google.com','child title','width=950,height=500');window.close();" onselectstart="return false;" ondblclickFunc="" stateful="false">
table content
</TABLE>
For some reason this closes both parent and child
Any idea why?
I have one html page (static html). Inside that I have anchor tag (.windowOpener), and a hidden div(.status) which shows the status. When user clicks the anchor tag, a window gets opened:
Click here
<div class='status' style='display:none'>Successful</div>
On click of this link, a separate window gets opened. In this new window, there is one link as
<a class='paymentButton' href='javascript:void(0)'>Do the payment</a>
Now on click of this anchor tag (.paymentButton), I want to close the new window and want to make the 'status' div visible in the first window. I don't want to use the modals.
Is it possible to do this? Any help will be appreciated...
Thank you in advance.
Use window.parent to access the parent window:
$(document).on('click', '.paymentButton', function() {
parent.showStatusDiv();
});
And declare showStatusDiv() function in the parent window:
function showStatusDiv() {
$('.status').show();
}
NOTE
In case of more that one level of windows, use window.top to access the top most window
I have openned my application in a Internet explorer tab say "TAB1" , and by clicking a button say "button1" in the "TAB1" , a pop-up say "POP-UP1" will open, in the "POP-UP1" screen if i click a button, it will add some elements in the "TAB1"screen (Parent screen 1) .
Now i open my same application in the another tab say "TAB2" in the same IE browser window and click the "button1" which opens the pop-up in the Same
"POP-UP1" (because the window.open() function code is same with the same pop-up name). Now when i try to add some elements in the "TAB2" (parent screen 2), But instead of adding to "TAB2", it adds the elements in the "TAB1" screen.
How to write the javascript code to add elements in the correct parent screen from whichever the pop-up is initiated. I want the same pop-up to work for all the tabs openned instead of openning many pop-ups from different tabs.
Please help me.
I think is because the name of the popped window is the same:
the parent.opener of the popup is the first tab... so it will always refer to it.
All I can think of is to have a different popup-name
for each tab the site is opened.
This way you will have 2(or more) popups and each will refer to his own parent.oopener.
try this :
var myTime=new Date().getTime();
var popupName="mypopup_"+myTime;
var myPopup=null;
function popMypopup(URL){
myPopup=window.open(URL,popupName,"height=50,width=50");
myPopup.focus();
}
to pop the window use
popMypopup('your/url/here.html')
You can try to see if the parent opener of the popup refers to the current window... if it doesn't close it and reopen it.
Something like this:
var myPopup=null;
function popMypopup(URL){
myPopup=window.open(URL,"mypopup","height=50,width=50");
myPopup.focus();
if(myPopup.parent.opener!=window){
myPopup.close();
popMypopup(URL);
}
}
PS: only tested on IE ... but I believe it should work on all browsers.
I want to show a child window which will perform some action and it will set to the parent window. The time when child window is open , parent window should be disable.
I tried this which return child window but parent window still in working mode while child window is open...
<a href="AddChoice" onclick="var x = window.open('url',,'','hemenubar=yes,height= 300,
width = 500,,scrollbars=no,dialog=yes,minimize=no,maximize=no,
alwaystop=yes,copyhistory= no,resizable=yes,toolbar=no,directories=no
,location=no,menubar=no,status=no,left=0,top=0');return false;">
Change Dependent Question...</a>
//This link returns a child window
You should use a modal dialog box. there are many ways to do that.
you can use some existing plug-ins.
jquery: http://www.designlabelblog.com/2009/03/20-ways-to-create-javascript-modal.html
YUI: http://yuilibrary.com/yui/docs/panel/panel-form.html
This is what I am trying to do: Once submit a form on my main JSP/HTML page a new page with some link opens. When I click on any of the link the link should open in the parent Window. I.e the Window I started from. How do i do this?
Use window.opener.location.href in javascript
For example,
Click me!
You'll need JavaScript for this. HTML's target can't target the window's parent (opener) window.
The following will open the page in the parent window if JavaScript is enabled, and open it in a new window if it is disabled. Also, it will react gracefully if the current page does not have an opener window.
<a href="page.php"
onclick="if (typeof window.opener != 'undefined') // remove this line break
window.opener.location.href = this.href; return false;"
target="_blank">
Click
</a>
MDC Docs on window.opener
Use parent.location.href if it's on the same page in an iframe. Use opener.location.href if it's another entire tab/window.