0

I'm calling a webpage from a mobile device (a motorola MC55A0).
The browser is IEmobile.
The page has a button on it, a press on that button calls some javascript code ending with the line:

window.close();

The javascript executes fine until that line, where nothing happens.
The browser is expected to close but doesn't.

What could be the cause of that behavior?

EDIT: I would like to add that the same webpage worked on another mobile device, with Windows CE 5.0 (Motorola MC3000 series)

madgangmixers
  • 150
  • 1
  • 16

1 Answers1

2

remember that: you can fire window.close() only on windows that have been opened with window.open()

See: Scripts may close only the windows that were opened by it

This method is only allowed to be called for windows that were opened by a script using the window.open method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.

that's the "nothing happens" you're facing. actually it's not absolutely nothing- a script message has been printed to the console.

hope that helps.

geevee
  • 5,411
  • 5
  • 30
  • 48
  • thanks for your answer Gal V. I've already tried calling window.open('','_self','') just before the close, but with no success. – madgangmixers Nov 20 '13 at 13:46
  • the window you're trying to close, how was it opened? with a `window.open()`? if not, it's impossible to close it with `window.close()`... – geevee Nov 20 '13 at 13:48
  • As I added in the initial question, it used to work on another device. I'm not sure it's impossible. – madgangmixers Nov 20 '13 at 13:53
  • from what you're describing, it might be a security breach on the other device. window.close shouldn't work just like that, that's why websites you're visiting at will never close the main window, only popup windows opened by the websites themselves. – geevee Nov 20 '13 at 13:55
  • I don't see how it would be a security breach to close itself. This code works well in iexplore desktop, chrome, safari : CLOSE – madgangmixers Nov 20 '13 at 14:26