Permission Denied when accessing parent from child window

Posted on 2009-05-22
Medium Priority
Last Modified: 2012-05-07
I have a window that uses Javascript to add rows to an HTML table on its parent window.  That works fine and I then press 'save' on the parent window to commit it to the database and refresh the screen with the new data.
However, when I again try to access the parent window's element from the child's (even just referencing some component), I get a Permission Denied javascript error.  It seems like when the parent window refreshes, the image of its contents changes (although the content are the same).  For example, trying table.addRow, deleteRow, or even referencing table.rows.length, cause the error.  Both windows are in the same domain so cross-site scripting restrictions shouldn't be an issue.  I'm using ie7.
Is there a way for the child window to reference the parent after the parent refresh, or is there another issue involved?  
Question by:leclaude
  • 3
LVL 39

Expert Comment

ID: 24453046
Unfortunately, there's indeed another issue involved. The child window only has access to the parent window if the parent window created the child window (confusing, I know, but that's how it works). This is a security measurement, to prevent you from popping up a window that can gain control over any other window, whether they show google.com, experts-exchange.com or your site.

This is one of those security cases where the good guys suffer from the behavior of the bad guys. But other then instructing your users to lower their security, or to close and reopen your child window, you cannot do much I'm afraid.
LVL 39

Accepted Solution

abel earned 1500 total points
ID: 24453059
A little update whilst thinking it over: one thing that will work is putting your parent window inside a frame (or iframe). The inner frame will have access to the parent window, and your child window will not loose the access to the parent window.

There may be other techniques that I currently cannot think of, to go around this restriction.

Author Comment

ID: 24904002
I was actually able to fix this.  I was setting the variable that held the parent element items to null if the element wasn't found.  Instead I need to re-reference it when the page refreshes and that fixed the problem.
LVL 39

Expert Comment

ID: 24905575
Glad you sorted it out. You can select your own comment as answer, or select your own comment as answer and give some points for the effort the expert(s) have invested in helping you... ;)

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question