• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

permission denied error

Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
In my application i have popup window opened via window.open from the parent page ,in the child page i add data and then submits the parent page from the child page(using window.opener.forms[0].submit())so that the added data gets reflect in the parent window and this worked fine.Now i have a new requirment that after opening the child window if the parent window is navigated to any other page the child window should get closed, so onbodyunload of the parent window i checked the reference of the childwindow not equal to "undefined" and closed the child window.This works fine ie. my child window closes when i keep my child window open and navigate the parent window to some other page.But when i add the data in the child page and submits(onunload is called now) the parent window to reflected the added data i get a permission denied error in the parent window where i try to close the child window. but i am not gettin this error constantly it occurs sometimes.
my code:

var childWindow=window.open("childWindowURL"...)

in the onunload function
childWindow.close() //This line gives the error.

both the pages are in the same domain. I dont want to use a modal window because it is not supported by all browsers. where am i going wrong
[ January 09, 2007: Message edited by: prem kamal ]
Posts: 15385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
might want to close the child right when you submit the form with self.close()

You might alwo want to stick a try catch block around the close() so your users will not see errors.

your check really should be

if(childWindow && !childWindow.closed)

No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic