简体   繁体   中英

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". One user reported that she was using Samsung Fascinate with "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

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" )

    <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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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