Close browser when using Iframe

VBdotnet2005
VBdotnet2005 used Ask the Experts™
on
I have an aspx page where it contains two iframes, top for navigation and bottom for contains. I want to put  link on top ifram where when click, I want to close the entire browswer.
So far I have found no solution.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
For security reasons, you can not browser window/tab through Javascript windows.close() function, unless it is opened/created by your web applications/site.

window.close() or self.close() will work, only if window is open by javascript


e.g.

function openWin() {
    myWindow = window.open("", "myWindow", "width=200, height=100");   // Opens a new window
}

function closeWin() {
    myWindow.close();   // Closes the new window
}
Manager / Solutions Architect
Commented:
Well, you can try this hack:
function CloseWindow() {
  var cWindow = window.open(window.location, '_self');
  cWindow.close();
}

Open in new window

Basically, it simulates the opening of the window in itself and closes it right after.
It should work everywhere.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial