The moose likes HTML, CSS and JavaScript and the fly likes JavaScript Permission Denied...sometimes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript Permission Denied...sometimes" Watch "JavaScript Permission Denied...sometimes" New topic

JavaScript Permission Denied...sometimes

Mary Mascari

Joined: Jun 26, 2002
Posts: 2
I know that you get a permission denied error when you try to modify a window from a different domain.
I'm getting the problem in my application, but the domains are the same. It happens intermittently, which is the most frustrating part.
Here's what's happening. I've got a form with some fields in it, and a link to launch a popup to allow the user to search for values to put into the form. They click on the value and poof! the form field is populated with that value.
productSearch =,'productsearch');
productSearch.opener = self;
Any thoughts?
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
Hi Mary,
I am taking a guess, but could the problem be that you're specifying the opener in the opener? It seems logical to me that "opener" might be a private object to each page, as allowing another page to set it might be a security issue. In my experience, the child window ought to know its opener without it being explicitly set.
Mary Mascari

Joined: Jun 26, 2002
Posts: 2
Tried it - no good.
Any other suggestions?
Mohamed Yousuff
Ranch Hand

Joined: Jun 23, 2001
Posts: 73
From the parent window, the child window must be opened using relative URL and not the absolute URL even though they belong to the same domain. By doing this, the 'access denied' error will not appear again. For example, lets say, the domain is;
productSearch ="/search",'productsearch');

(productSearch.opener = self; No need for this line). Note the relative path URL in the parent window script when opening a new window. If the same code in the parent window is written as
productSearch ="",'productsearch'), you will encounter 'Access Denied' error.

I have personally experienced this problem and solved it using the solution that I presented above. I am sure, it will work for you too. Best of Luck.

S.Mohamed Yousuff

Originally posted by Mary Mascari:
Tried it - no good.
Any other suggestions?
Harshil Mehta
Ranch Hand

Joined: Mar 17, 2005
Posts: 64
Hello Ranchers,
reopening a very old post! further to solution given by Mohamed Yousuff, what if the window opened by parent window is not on the same domain?

Is there really no way to make communication possible between parent window and child window specially calling parent window's javascript function by child window's java script function?

I am facing this problem as:
  • My parent page has a select box where person's names are supposed to be displayed.
  • In order to enter names in this box, user is dependent on centralized repository of names.
  • This is not a database like sybase or oracle so my java code cannot user it directly via jdbc. So the user clicks on a button that opens up a child window with URL of different domain.
  • This window loads content where user can search for users which are required to be entered and upon finishing search, user clicks on button of child window which calls a javascript function of parent window with passing search result as string as parameter to it.

  • Here the error Permission Denied appears on child window. I am really stuck. Is there any workaround of this problem?


    [ October 10, 2006: Message edited by: Harshil Mehta ]
    [ October 10, 2006: Message edited by: Harshil Mehta ]
    Md Uddin
    Ranch Hand

    Joined: Jan 11, 2006
    Posts: 30
    @Mohamed Yousuff: I know I am replying to a very old post here. But I couldn't resist my self not thanking you. I have searched the net for the solution for last couple of days and no one has this simple solution.

    Thank you again. This information was really helpful.

    MURAD (SCJP 5.0, SCWCD 1.4)
    If you learn to program in Java, you'll never be without a job! (Patricia Seybold in 1998) - Knowing the syntax of Java does not make someone a software engineer. (John Knight)
    Eric Pascarello

    Joined: Nov 08, 2001
    Posts: 15385
    Impossible to talk to another domain like this for security reasons. Do you want your bank account to be opened and manipulated while watching an online video?

    I agree. Here's the link:
    subject: JavaScript Permission Denied...sometimes
    It's not a secret anymore!