Search code examples
javascriptjquerypopupxsssame-origin-policy

Why does my JavaScript / jQuery interaction with a child window raise a "permission denied" error?


I have some code that I would swear was working a month ago. However, now the code throws a permission denied to get property Window.jQuery error. I can see this error in the Firefox error console.

The code in question belongs to a window that was opened via JavaScript. This code attempt to update the contents of a DIV in the opening page. In an attempt to update this DIV, I try to access it using the following script:

var confirmDiv = window.opener.jQuery("#confirmDiv");

However, this line is what triggers the permission denied error. Can someone explain to me how to use jQuery to update the contents of a DIV in an opening window?


Solution

  • XSS error. You're being denied because of the same origin policy, and yeah, it probably worked a month ago, before some set of anti-XSS patches.

    In order to do this, your JS and the content it's manipulating need to be from the same domain.