(自分のサーバーにある)テスト用Webページを読み込もうとしています。ページは:Android WebView「要求されたリソースにAccess Control-Allow-Originのヘッダーが存在しません」
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<iframe width="420" height="315" src="http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=1"/>
</body>
</html>
webViewはページを読み込んでいません。また、この問題は、URLからjsスクリプトをロードするすべてのサイトで発生します。 ここでユーチューブ、FBなど
WebConsole: XMLHttpRequest cannot load https://googleads.g.doubleclick.net/pagead/id. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.youtube.com' is therefore not allowed access.
私の設定
FrameLayout contentFrame = (FrameLayout) findViewById(R.id.ContentFrame);
WebView mWebView = new WebView(this);
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
mWebView.loadUrl("http://ozgur.dk/browser.html");
contentFrame.removeAllViews();
contentFrame.addView(mWebView);
レイアウトを含む:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="@+id/ContentFrame"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
同様の質問を参照してください。http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource and http://stackoverflow.com/questions/20433655/no-access-control-allow-origin-header-present-on-the-requested-resource-of- – user861594