Android 애플리케이션의 webview에서 로컬 HTML 파일을로드하려고합니다. HTML 파일은 jquerymobile.js
의 로컬 사본을 참조합니다. 내 문제 는 응용 프로그램이 실행될 때, 다음과 같은 오류가 발생입니다 : 내가 jQuery 라이브러리를에서로드 할 때
TypeError 'undefined' is not an object (evaluating $ event)
이 발생하지 않는 jquery lib
.This 오류를 사용하여 작성된 코드 없이도 일이 자신의 CDN
.
내가 뭘 잘못하고 있는지에 대한 아이디어가 있습니까? 시간 내 주셔서 감사합니다. 더 선명도
추가 코드 :
이다 어디 WebView
로드 url
try {
//this reads the jquerymobile as a string
jmobile = readFileAsString();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
wview1.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
//Required functionality here
return super.onJsAlert(view, url, message, result);
}
});
wview1.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(wview1, url);
wview1.loadUrl("javascript:"+jmobile);
// do your stuff here
}
});
wview1.loadUrl("file:///android_asset/html/index.html");
다음 작품
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
하지만 스크립트를 변경하는 경우 src t o jquery.mobile-1.1.1.min.js의 로컬 복사본
감사합니다.하지만 오류가 계속 발생합니다 : null에서 undefined의 'event'속성을 읽을 수 없습니다. – DroidRam
안녕하세요 DroidRam, 코드를 보여 주시겠습니까? –
시간 내 주셔서 감사합니다. 제 질문에 코드를 추가했습니다. – DroidRam