Uncaught Error: SECURITY_ERR: DOM Exception 18 -- From line 36369 of file:///sdcard/main2.html
Uncaught Error: SECURITY_ERR: DOM Exception 18:36369
아래 소스를 통하여 웹뷰에 로드된 m.naver.com를 소스와 같이 html 소스코드로 뽑아서
파일로 만들어 다시 webview로 해당 파일을 로드 하였더니 위와 같이 에러가 발생하였습니다.
위 에러는 약 3초간 계속 적으로 발생하면서 웹뷰안에 있는 네이버 화면 아래에 동일한 화면이 계속적으로 추가되었습니다.
화면 클릭도 안되구요;;
고수님들 조언 부탁드립니다.
public class FullscreenActivity extends Activity {
static public final String LOG = "### LOG ###";
public WebView wb = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
wb = (WebView)findViewById(R.id.web);
wb.getSettings().setJavaScriptEnabled(true);
wb.addJavascriptInterface(new ForSource(), "ForSource");
wb.getSettings().setLoadsImagesAutomatically(true);
wb.getSettings().setLoadWithOverviewMode(true);
wb.getSettings().setUseWideViewPort(true);
wb.requestFocus();
wb.getSettings().setDatabaseEnabled(true);
wb.getSettings().setDomStorageEnabled(true);
wb.getSettings().setDatabasePath(this.getApplicationContext().getDir("database",Context.MODE_PRIVATE).getPath());
wb.setWebViewClient(new GTIWebViewClient());
wb.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
wb.setWebChromeClient(new ChromeClient());
wb.getSettings().setAppCacheEnabled(false);
wb.getSettings().setDomStorageEnabled(true);
wb.loadUrl("file:///sdcard/main2.html");
}
private String DownloadHtml(String string) {
File file = new File("/sdcard/main.html");
// StringBuilder html = new StringBuilder();
String line = "";
try{
FileWriter fw = new FileWriter(file);
BufferedWriter bw = new BufferedWriter(fw);
URL url = new URL("string);
HttpURLConnection connect = (HttpURLConnection)url.openConnection();
if(connect!=null){
connect.setConnectTimeout(1000);
connect.setUseCaches(false);
if(connect.getResponseCode()==HttpURLConnection.HTTP_OK){
BufferedReader br = new BufferedReader(new InputStreamReader(connect.getInputStream()));
for(;;){
line = br.readLine();
if(line==null) break;
bw.write(line + "\n");
bw.flush();
line = null;
// html.append(line+'\n');
}
br.close();
}
connect.disconnect();
}
}
catch(Exception ex){ex.printStackTrace();
Log.e(LOG,"Exception");
}
return "";
}
private class ChromeClient extends WebChromeClient {
@Override
public void onConsoleMessage(String message, int lineNumber,
String sourceID) {
Log.e(LOG, message + " -- From line " + lineNumber + " of " + sourceID);
}
@Override
public void onExceededDatabaseQuota(String url, String
databaseIdentifier, long currentQuota, long estimatedSize,
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
quotaUpdater.updateQuota(estimatedSize * 2);
super.onExceededDatabaseQuota(url, databaseIdentifier, currentQuota,
estimatedSize, totalUsedQuota, quotaUpdater);
}
}
private class GTIWebViewClient extends WebViewClient {
GTIWebViewClient(){
Log.e(LOG, "GTIWebViewClient");
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.e(LOG, "====shouldOverrideUrlLoading========");
wb.loadUrl("url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
Log.e(LOG,"onPageFinished url="+url);
String ht = "javascript:window.ForSource.print(document.getElementsByTagName('html')[0].innerHTML);";
view.loadUrl("ht);
}
}
private class ForSource {
@SuppressWarnings("unused")
public void print(String data) {
File file = new File("/sdcard/main2.html");
FileOutputStream fos;
try{
if(file.exists()){
fos = new FileOutputStream(file, true);
}else{
fos = new FileOutputStream(file);
}
fos.write(data.getBytes());
fos.close();
}catch (Exception e) {
Log.e(LOG,"print exception "+e.getMessage());
}
}
}
}