Javascript 未在Android Webview自定义渲染器中加载脚本文件

Javascript 未在Android Webview自定义渲染器中加载脚本文件,javascript,android,html,android-webview,Javascript,Android,Html,Android Webview,我已经使用Android WebView渲染器加载了本地html。html正在正确加载。但是html文件中引用的脚本没有加载。脚本文件位于“资源”文件夹中 渲染文件代码 protected override void OnElementChanged(ElementChangedEventArgs<HybridWebView> e) { base.OnElementChanged(e); if

我已经使用Android WebView渲染器加载了本地html。html正在正确加载。但是html文件中引用的脚本没有加载。脚本文件位于“资源”文件夹中

渲染文件代码

protected override void OnElementChanged(ElementChangedEventArgs<HybridWebView> e)
            {
                base.OnElementChanged(e);

                if (Control == null)
                {
                    var webView = new Android.Webkit.WebView(Forms.Context);
                    webView.Settings.JavaScriptEnabled = true;
                    if (Build.VERSION.SdkInt >= Build.VERSION_CODES.JellyBean)
                    {
                        webView.Settings.AllowUniversalAccessFromFileURLs = true;
                        webView.Settings.AllowFileAccessFromFileURLs = true;
                    }
                    SetNativeControl(webView);
                }

                if (e.NewElement != null)
                {

                    Control.LoadUrl("file:///android_asset/Sample/index.html"); 
                }
            }
protected override void OnElementChanged(ElementChangedEventArgs e)
{
基础。一个要素发生变化(e);
if(Control==null)
{
var webView=newandroid.Webkit.webView(Forms.Context);
webView.Settings.JavaScriptEnabled=true;
if(Build.VERSION.SdkInt>=Build.VERSION\u code.JellyBean)
{
webView.Settings.allowuniversalaccessfromfileurl=true;
webView.Settings.AllowFileAccessFromFileURLs=true;
}
SetNativeControl(网络视图);
}
if(例如NewElement!=null)
{
控件。加载URL(“file:///android_asset/Sample/index.html"); 
}
}
Html代码

protected override void OnElementChanged(ElementChangedEventArgs<HybridWebView> e)
            {
                base.OnElementChanged(e);

                if (Control == null)
                {
                    var webView = new Android.Webkit.WebView(Forms.Context);
                    webView.Settings.JavaScriptEnabled = true;
                    if (Build.VERSION.SdkInt >= Build.VERSION_CODES.JellyBean)
                    {
                        webView.Settings.AllowUniversalAccessFromFileURLs = true;
                        webView.Settings.AllowFileAccessFromFileURLs = true;
                    }
                    SetNativeControl(webView);
                }

                if (e.NewElement != null)
                {

                    Control.LoadUrl("file:///android_asset/Sample/index.html"); 
                }
            }

var book=ePub(“file:///android_asset/Sample/Azure_Cosmos_DB_and_DocumentDB_Succinctly/);
$(文档).ready(函数(){
账簿。renderTo(“区域”);
});       
‹
›    

通常,您会将脚本标记放在HTML的底部,而不是顶部

<!DOCTYPE html>
<html class="no-js">
    <head> 
    </head>
    <body>
 <div id="main">
    <div id="prev" onclick="book.prevPage()" style="font-size: 64px;cursor:pointer;" class="arrow">‹</div>
    <div id="area" ></div>
    <div id="next" onclick="book.nextPage()" style="font-size: 64px;cursor:pointer;" class="arrow">›</div>    
</div>    
    </body>
<script src="file:///android_asset/jquery-1.10.2.min.js"></script>
<!-- Render -->
<script src="file:///android_asset/epub.min.js"></script>
<script type="text/javascript">
    var book = ePub("file:///android_asset/Sample/Azure_Cosmos_DB_and_DocumentDB_Succinctly/");
    $(document).ready(function () {
        book.renderTo("area");
    });
</script>
</html>

‹
›    
var book=ePub(“file:///android_asset/Sample/Azure_Cosmos_DB_and_DocumentDB_Succinctly/");
$(文档).ready(函数(){
账簿。renderTo(“区域”);
});

您还忘记了在
var book=ePub(“file:///android_asset/Sample/Azure_Cosmos_DB_and_DocumentDB_Succinctly/");

嗨,史蒂文,谢谢你的更新。我已将脚本部分移到底部,并在调用epub时更正了缺少的引号。甚至脚本都没有渲染。我的错,我现在看到了另一个错误。只需要说:src=“android_资产/jquery-1.10.2.min.js”而不是src=”file:///android_asset/jquery-1.10.2.min.js“android_资产文件夹是否位于您的www文件夹中?