window.close...

  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post April 14th, 2003, 2:33 am

ok im having problems closing a window its the index page of my site and i have it redirecting to another page (my home page) ive only done this for a short time until i make a 1024x768 page so at the moment i have just shortcutted by making a new page centering it keeping it at 800x600 and made it so it is unresizable i know i shud make 2 pages and then make it so it loads the right one onload but i havent got the time lol its at http://www.onspring.co.uk hopefully u can get to it this time cos last time u cudnt for some reason
thanx for any help
d7
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 14th, 2003, 2:33 am

  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post April 14th, 2003, 2:36 am

oops i didnt ask the question i wanted to ask lol i meant.... i need it to close without the user clicking the ok in the box i know its possible but ive spent time playing around with it and what ive seen is that if u load it in javascript then u can close it without the message box comin up i just dont know how to make it so it doesnt bring up the message box
d7
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 6382
  • Loc: twitter.com/unflux
  • Status: Offline

Post April 14th, 2003, 6:57 pm

put this as your link:
Code: [ Select ]
<a href="javascript:parent.close()">Close this window</a>

that should do it. :D
UNFLUX.FOTO
  • Steen
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 15, 2003
  • Posts: 343
  • Status: Offline

Post April 19th, 2003, 7:14 am


No, that doesn't do it.
it still prompts the dialog box from Windows OS to warn that
this site is trying to close, do you want to allow such?

I've dealt with this before.

I'll have to look around but I recall it would only work properly
if you still had a console from that same domain still open in the background.

The DOM, Document Object Model is not being closed by the user,
the warning comes up because the code selected on the DOM is trying
to close it, thus it asks for user permission.

I foget how we dealt with this problem,
I'll have to check, I do believe we ended up popping
a console while keeping one in the background.

but then again, I would only want to put further effort into this,
if you still needed to resolve this problem.
  • Steen
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 15, 2003
  • Posts: 343
  • Status: Offline

Post April 19th, 2003, 8:32 am

I wonder if you couldn't just null out the window.alert(string)
within the window.close event.
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 6382
  • Loc: twitter.com/unflux
  • Status: Offline

Post April 19th, 2003, 9:02 am

oh, i forgot about the "same domain" thing. thx for catching that steen.

No reply from him yet hmm...
UNFLUX.FOTO
  • Steen
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 15, 2003
  • Posts: 343
  • Status: Offline

Post April 19th, 2003, 9:47 am

Apparently you can avoid the alert
if there is only one location in the window's history, so if you open a
child window and close it from within the child window, there is no
message.

It's a Microsoft Security thing!

This problem is not an issue when doing HTA's (applications)
as in:
Invoking the window.close method on an HTA closes the application without prompting the user because the HTA is trusted and follows a different security model.


but in the broswers, it's not the same.

http://msdn.microsoft.com/library/defau ... lose_0.asp


To this date, this is still a *peach* up issue.

I've read comments on flushing out the history before going
to a child window but I'll be damned it I can find a sample anywhere.

sorry ...
  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post April 20th, 2003, 9:40 am

sorry flux i been away a while and forgot about this lol but yea steen is rite it dont work but i have seen examples of it working but only on click and not onload security thing how annoying lol
d7
  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post April 25th, 2003, 6:25 am

well after all that looking around at the time i suddnely coem across it earlier while looking for something else but here it is the code that stops it from prompting u asking if u want to close the window so its what uve all been waiting for lol..
Code: [ Select ]
window.opener = null
window.close()
return false
  1. window.opener = null
  2. window.close()
  3. return false

so ppl put this after ur window.open() statement or if u want to just close the window wen u click it then its..
Code: [ Select ]
<a href="#" onclick="window.opener=null; window.close(); return false">thelinkbuttonorwhatever</a>


ok ppl i hope that helped y'all it definitely helped me lol
d7
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post April 25th, 2003, 1:43 pm

Oh very nice glad to see you figured it out and maybe it will help many others now :D
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 6382
  • Loc: twitter.com/unflux
  • Status: Offline

Post April 25th, 2003, 5:38 pm

oh that's fantastic! thanks dreamer7...it will def help others. :D
UNFLUX.FOTO
  • Steen
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 15, 2003
  • Posts: 343
  • Status: Offline

Post April 26th, 2003, 6:28 am


hahaha ...

yeah that 'null' thing works for a lot of things very well.

glad to see you managed, I know I had a hard time finding something,
yet knew it could be done.

I'd be interested in the whole code if you have it.

thanks,
  • Steen
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 15, 2003
  • Posts: 343
  • Status: Offline

Post April 26th, 2003, 6:40 am


that works great.

thanks a ton,
I saved it and it's a keeper.
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 6382
  • Loc: twitter.com/unflux
  • Status: Offline

Post April 26th, 2003, 11:12 am

umm...isn't this the whole code?
Code: [ Select ]
<a href="#" onclick="window.opener=null; window.close(); return false">thelinkbuttonorwhatever</a>
:?: :?:
UNFLUX.FOTO
  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post April 26th, 2003, 4:00 pm

erm to close a window by clicking on it yes why u found a problem???? :shock: :(
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 26th, 2003, 4:00 pm

Post Information

  • Total Posts in this topic: 24 posts
  • Users browsing this forum: No registered users and 136 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.