简体   繁体   English

Android Webview href无法正常工作

[英]Android Webview href not working

I am using the following code in my Webview along with Jquery Mobile, This works fine in the emulator (2.2 ) and on my Nexus one but some users are complaining that when they click on a link they get an error message "Problem with File: Requested file not found". 我在Webview和Jquery Mobile中使用了以下代码,在模拟器(2.2)和Nexus 1上都可以正常工作,但是一些用户抱怨单击链接时会收到错误消息“文件问题:找不到请求的文件”。 One user reported that she was using Samsung Fascinate with "2.2.1" . 一位用户报告说她正在将Samsung Fascinate与“ 2.2.1”一起使用。 This seems to have started when I upgraded jquery mobile 1.0b2 , I have tried the latest 1.0rc but still have the same issue 当我升级jquery mobile 1.0b2时,这似乎已经开始,我尝试了最新的1.0rc,但仍然存在相同的问题

Any Insights on what might be happening ? 对可能发生的情况有任何见解?

In my Activity 在我的活动中

engine.loadUrl("file:///android_asset/book2/www/newindex.html");

In the html ( I have also tried data-ajax="false" ) 在html中(我也尝试过data-ajax =“ false”)

    <link rel="stylesheet" href="jquery/jquery.mobile-1.0rc1.min.css" /> 
    <script type="text/javascript" src="jquery/jquery.mobile-1.0rc1.min.js"></script>


    <div data-role="page" id="jqm-home">
    <div data-role="content" data-theme="e">   
        <div class="content-primary">   
    <nav>             
    <ul data-role="listview" data-inset="true" data-theme="e" data-dividertheme="d" >
    <li data-role="list-divider">Cognitive</li>

        <li><a rel="external" href="./cogn/simon2.html">
            <img src="cogn/simon.jpg" />
            <h3>Simon says</h3>
            <p>Memory</p>
        </a></li>

From what I know about URL loading, if you are loading a local file, which is what it looks like here, that file needs to be in the same directory as the file its linking from. 根据我对URL加载的了解,如果要加载本地文件(如此处所示),则该文件必须与其链接所来自的文件位于同一目录中。 Because the file is local on your computer, your device and emulator should work fine. 由于该文件在您的计算机上是本地的,因此您的设备和仿真器应该可以正常工作。 for someone else who downloads the app and tries to use the Webview functionality, that source file would need to be stored in their phone and in the appropriate directory...hope that helps. 对于下载该应用程序并尝试使用Webview功能的其他人,该源文件将需要存储在手机中和适当的目录中……希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM