Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript Permission Denied...sometimes

 
Mary Mascari
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Parent:
productSearch = window.open(searchUrl,'productsearch');
productSearch.opener = self;
Child:
opener.document.forms[0].month.value=month;
Any thoughts?
Thanks.
 
Garann Means
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
g.
 
Mary Mascari
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried it - no good.
Any other suggestions?
 
Mohamed Yousuff
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 www.xyz.com;
Parent:
productSearch = window.open("/search",'productsearch');
Child:
opener.document.forms[0].month.value=month;

(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 = window.open("http://www.xyz.com/search",'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
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

    --Harshil

    [ October 10, 2006: Message edited by: Harshil Mehta ]
    [ October 10, 2006: Message edited by: Harshil Mehta ]
     
    Md Uddin
    Ranch Hand
    Posts: 30
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    @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.
     
    Eric Pascarello
    author
    Rancher
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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?

    Eric
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic