• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
if(childWindow!="undefined"){
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 ]
 
author
Posts: 15385
6
  • 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)

Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic