Jump to content

Accessing parent window from child window?


BobbyRachel

Recommended Posts

I have a main window named worklistManager.jsp. worklistManager.jsp has a pop up window named processManager.jsp. Again, processManager.jsp has another pop up window, named eventLog.jsp. Once again eventLog.jsp has a pop up window named eventUsers.jsp. eventUsers.jsp has a dojox/grid/DataGrid and a button. After selecting a particular row in the grid, then clicking the button, it has to place the value into the textbox of eventLog.jsp after closing eventUsers.jsp. So far, I have tried the script below to accomplish this, but it's not working as I hoped.

<script type="text/javascript">	function getEventLogUserSelect(){	 if(dijit.byId('dynamiceventusergridCWUSER')){	 var selctedItem = dijit.byId('dynamiceventusergridCWUSER').selection.getSelected();		 if(selctedItem.length){		  dojo.forEach(selctedItem, function(selectedItem){		  if(selectedItem !== null){		  dojo.forEach(dijit.byId('dynamiceventusergridCWUSER').store.getAttributes(selectedItem), function(attribute){		  var value = dijit.byId('dynamiceventusergridCWUSER').store.getValues(selectedItem, attribute);		  if(attribute == "USERID"){		  window.opener.SetValue(value);		  window.close();		  }		  		  });		  }		  });		  //alert("grid row selected");		 }else{		  alert("grid row not selected");		 }	 }		if(gbshowgridFlag==false){		 alert("grid not loaded");		}	}	function SetValue(val){		var txt = document.getElementById('CWPROCESSEVENTLOG.USER_ID');		txt.value = val;			 }	</script>

Link to comment
Share on other sites

window.opener is the way to access the parent window, but the SetValue() function was only declared in the current window. You're going to have to work with what is available in the parent window. Putting this right where you invoked the SetValue() function should work:

var txt = window.opener.document.getElementById('CWPROCESSEVENTLOG.USER_ID');txt.value = value;

Link to comment
Share on other sites

You should never rely on popup windows. They are invasive, often confusing for the user (if their browser is full screen and the popup goes behind it, they have to mess about with windows to get it back), and if they're not blocked by a popup blocker - which a lot of people have enabled - they will often be ignored just because they're popups.

Link to comment
Share on other sites

(if their browser is full screen and the popup goes behind it, they have to mess about with windows to get it back)
Not if you do it such a way that it remains at front until closed, you can also do it to restrict the number of windows at given time. pop-blocker usually come with option to allow pop-up on this site option, before blocking completely, depends how you set it up.
Link to comment
Share on other sites

Not if you do it such a way that it remains at front until closed, you can also do it to restrict the number of windows at given time. pop-blocker usually come with option to allow pop-up on this site option, before blocking completely, depends how you set it up.
That sounds crazy invasive. What happens if I want to go to a different tab on the original window and then go back to the popup? Either way, it'll be ugly.I believe that Chrome blocks all popups by default, and doesn't notify the user. Even so, if something comes up saying "popup blocked", most users now just associate popups with spam and so don't tell it to open the popup.
Link to comment
Share on other sites

How can it be invasive, one pop-up, light-box is classed as a pop-up, you are restricted to the LB pop-up until you are finished with it and then close it, and it is used everywhere, and if you are on a trusted site, you would NOT associate spam with that site so you would enable it, its the new sites you have not visited before you should be wary of, even this site uses a pop-up for login screen, but it has fallback to login page, as for going from parent page to pop-up, usullay the pop would not usually contain info from which you would want to keep returning, unless you have memory of goldfish, and can't remember what you just seen. IF its important info, you usually get the option to print it!

Link to comment
Share on other sites

How can it be invasive, one pop-up, light-box is classed as a pop-up, you are restricted to the LB pop-up until you are finished with it and then close it, and it is used everywhere, and if you are on a trusted site, you would NOT associate spam with that site so you would enable it, its the new sites you have not visited before you should be wary of, even this site uses a pop-up for login screen, but it has fallback to login page, as for going from parent page to pop-up, usullay the pop would not usually contain info from which you would want to keep returning, unless you have memory of goldfish, and can't remember what you just seen. IF its important info, you usually get the option to print it!
I get the impression that you don't know what invasive means and that you'd also happily use alert and prompt, light boxes are not popup windows, I'm not sure where you got that from, light boxes are also pretty invasive though, you shouldn't assume that your users will trust you, as a lot of your users won't and you want the website to work for them too, I don't have the memory of a goldfish but I still couldn't remember the beginning of your post when I got to the end of the post, please use sentences and try to not ramble.
Link to comment
Share on other sites

lightbox can include iframes, and other html content, not only pretty image galleries you know, so apparently you don't know much about lightbox either, still stuck in the old age, you will find pop-ups of all sorts on all major sites BBC for instance, if it is used sensibly, and in the right situation it is perfectly fine, just to come out and say never use pop-ups it is invasive, and confusing ( you seem to like using the 'confuse' word, it obviously may be confusing to you, but for majority i don't think it is anything of the kind ) is a stupid ridiculous statement to come out with.

Link to comment
Share on other sites

Media would be an exception for the popups rule, but even then it would be better off without.Again, please learn what invasive means. You seem to be confused. I'm not.

Edited by callumacrae
Link to comment
Share on other sites

You really think i don't know invasive means, really! you really want to go down that route, you really think i am as dumb as you, you come with a arrogant attitude, 'you should not do that, you must do this', and its plain to see you just have not got a clue. Just answer the question the OP asks, suggest a better way, but don't just dismiss a someone answer, and demand to do it your way.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...