Reputation: 113
Intro
Below I've got my seriously customized webview (in the OnCreate of my activity)..
WebView waw = (WebView) findViewById(R.id.webView1);
waw.getSettings().setBuiltInZoomControls(true);
waw.getSettings().setSupportZoom(true);
waw.getSettings().setSupportMultipleWindows(true);
waw.getSettings().setLoadWithOverviewMode(false);
waw.getSettings().setJavaScriptEnabled(true);
waw.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
waw.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
waw.getSettings().setUseWideViewPort(false);
waw.setWebViewClient(new WebViewClient() {
public void onReceivedError(...)
//Show error toast here.
}
});
waw.loadUrl("http://mysecreturl.com");
So, after much effort here's everything I've done:
My activity opens in full screen, entirely made up of webview... I start straight away by opening a URL, I've enabled the build in Zoom controls for the pinch zoom, set a default zoom etc.
Problematic Stuff
So, in the website that I'm trying to open, I snooped around the page source, and I found this is exact button that's causing my problem.
<button><img src="img/Start.png" onclick="javascript:startSurf()"></button>
It has an image, Start.png, and a function I could not find the exact code of.
This is what I want to open. But can't. I press, and nothing happens, It just ignores the click on this particular button (other links work just fine).... It's got something to do with JavaScript (99% sure)
The links and everything else works just fine, I think this is the only one button that uses JavaScript so maybe that's causing a problem.
When I try doing this, say in Google Chrome on my PC or even the default android browser( on mobile) ... When I press this button (at the same URL) ... a pop-up window appears with a webpage. That's what I want.
Right now I just want it to just open, just do something when I press the button. It can open wherever it wants, a new window, the same page, use the default browser -anything.
I've tried everything I can. (see above) .. I've enabled java script, enabled multiple windows, enabled JS to open a window - Absolutely no change.
(Well, small change - Without enabling these, the OnPress animation of the button didn't work, Now we can see the button is pressed but it still doesn't do anything. Again, I'm talking about the button with the JS function on the website I'm trying to use)
So, How to solve this?
Thank you :-D
Upvotes: 3
Views: 2462
Reputation: 130
It may be some cross-domain policy issue, you may try to workaround this by overriding shouldOverrideUrlLoading in the WebViewClient instance, also, take a look at loadDataWithBaseURL().
Upvotes: 1
Reputation: 1767
Try this;
<a href="#" onclick="startSurf(); return false;"><img src="img/Start.png"></a>
or
<button><img src="img/Start.png" onclick="startSurf()"></button>
Upvotes: 0