Agus
Agus

Reputation: 1614

How to close a windows open from (javascript) by issuing window.close

I am working in Android with WebView that load javascript. I've succeeded to load the page, js and so on. Moreover I've succeeded to open a new windows by using

Previous to load the index.html, I allows the use of JS in the Activity

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.loadUrl("file:///android_asset/index.html");

After the index.html with JS is loaded, I succeeded to open a windows.

 myWin=window.open("http://www.google.com") at js

But, when I issued the close signal, the page still open.

 myWin.close();

Do you have any idea?

Upvotes: 3

Views: 4175

Answers (2)

Ash
Ash

Reputation: 3581

try arranging the sequence of your code it matters. May be you are using javascript before enabling javascript.

Upvotes: 1

kabuko
kabuko

Reputation: 36302

You have to implement onCloseWindow in your WebChromeClient. Otherwise there's no way for your app to know what closing a window means in terms of your views.

Upvotes: 2

Related Questions