0

我正在尝试启用 javascript,我认为我做对了,但是当我在手机上运行它时,它似乎没有加载 javascript。我还想知道如何在 webview 之外加载外部链接,因为现在我可以覆盖仅在我的 webview 中加载,我该如何将它翻转到我的网站之外的任何内容以从外部加载?

我把它放错地方了吗?

package com.webapp.area956;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {





@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WebViewClient yourWebClient = new WebViewClient()

        {
           // Override page so it's load on my view only
           @Override
           public boolean shouldOverrideUrlLoading(WebView  view, String  url)
           {
            // This line we let me load only pages inside Firstdroid Webpage
            if ( url.contains("area956") == true )
               // Load new URL Don't override URL Link
               return false;

            // Return true to override url loading (In this case do nothing).
            return true;
           }
       };

    String url = "http://www.area956.com";
    WebView view = (WebView) this.findViewById(R.id.webView1);
    view.setWebViewClient(yourWebClient);

    view.getSettings().setJavaScriptEnabled(true);

    view.loadUrl(url);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}
4

1 回答 1

0
   WebView view = (WebView) findViewById(R.id.webview1);
 view = (WebView) findViewById(R.id.webview);
  view .setWebChromeClient(new InredisChromeClient(this));
  view .setWebViewClient(new InredisWebViewClient(this));
  view .clearCache(true);
  view .clearHistory();
  view .getSettings().setJavaScriptEnabled(true);
 view .getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

设置这些属性

于 2013-10-27T05:33:31.217 回答