• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Child window accessing parent window error

 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In one of my pages I open up a child window with the URL of another website. The website's (in the child window) intent is to valid a user name and password. Upon successful entry of the username and password on the first page of this website this page gets redirected somewhere to have the user validated. If the user has supplied a good username and password the window then gets redirected to a page (of the same domain) as the calling parent page. In the "success" page that gets called in the child window I was hoping to have a javascript there that merely set some values on the parent (opener) window. I'm going to ask how to do that after trying such things as alert(window.opener.document.getElementById("validtextfield").value); has failed. It gives me an error (bottom left) that "Access is denied". What are the possible causes for this error to occur? Thanks in advance for any info/help.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Security.

Imagine the security ramifications if someone could write script to manipulate any random site.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably since the page left the domai, the window is marked as a security problem. What browser are we talking here IEXXX
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
Understandable Bear but I thought because the domain ends up being the same as the calling parent everything would be fine. Basically the parent page belongs to (keep it simple) domain A. The popup window calls domain B, user name and password are entered, form gets submitted elsewhere, validation occurs, on a pass the page then turns to a page belonging to domain A again. Would this redirection or such cause a problem with accessing the child window? Basically (the last page in the child window) I want it (it'll be a server side script) to store log in details in the session variable and then when the response gets sent to the client to have the child window change some HTML blocks of code on the parent window and then close itself.

Rob
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric... IE 7 is the browser I'm currently using.
 
Ranch Hand
Posts: 121
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob Hunter,

window.opener.document.getElementById("validtextfield").value is failed in the sense you are accessing this statement after you redirecting to another page when it got validated username and password.
either you store the credentials in to your parent window before redirecting or carry forward those values with the url your redirecting and then store those values to your parent window.
correct me if I am wrong, are provide some more information to help you out. because I played alot with parent-child window relation with javascript. I hope I can help you out if you provide the exact problem your facing.
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the browser page I'm on there is a "Log in" button that initializes a child window (i.e. window.open(...)). The page that actually loads is a jsp from a totally different domain. It's this page that prompts for a username and password, the form's action goes to another page (which happens far too quickly to see which one). The validation is done there. I supply the path of the "success" page and wherever the validation occurs handles transferring here. I'm unable to pass in values to tack onto the URL (well... I could but they aren't handled). The initial browser page (one that has the button to initialize logging in) has the "validtextfield" field. When the "success" page gets hit I want to hide the log in button and display a message (along the lines of Welcome <user>!). On the success page (which is actually a CGI script written in Perl) I have an in-line javascript that tries to handle communication with the parent window (main browser page).
Going by what you wrote, are you saying that because the initial child's page has been left behind I have no access to the parent window? The main issue here is not passing values to the success page but rather having the success page modify/access the parent window after it has determined whether the login passed or failed. I need to dynamically change the parent page accordingly to the response I get from the external application doing the validation. Does that make sense? If not let me know if you have any questions to help clarify. Thanks for the response.
 
suresh dasari
Ranch Hand
Posts: 121
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob Hunter,

I tried with a sample example as you explained, I traversed form domain A to domain B and then redirected to domain A and called the parent input text control --- it is working fine in Firefox and IE7
I hope there might be some security problems when your moving from one application to another application.
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic