【问题标题】:Why won't my HTML links work in PhoneGap/Eclipse?为什么我的 HTML 链接在 PhoneGap/Eclipse 中不起作用?
【发布时间】:2011-04-17 01:56:34
【问题描述】:

我用 HTML/CSS 创建了一个应用程序。它在 iPhone 上运行良好。现在我正在使用 Eclipse 中的 PhoneGap 将它移植到 Android。我已使用此页面作为起点:phonegap / phonegap-android-eclipse-quickstart 当我按照该教程并在我的 eLocity 中打开它时,它会正确启动,并打开 index.html 作为主页。

我的新 index.html 页面替换了上面教程中使用的页面,其中充满了 <li></li> 列表中的普通 HTML <a href="1000.html"> 链接,这些链接将您带到同一文件夹 (www) 或下一个文件夹中的其他 HTML 页面文件夹(章节/1000.html)。但是当我在我的 eLocity 平板电脑中启动它时,链接不会触发。 <li> 区域会变成应有的蓝色,但页面不会改变。

为什么普通的 HTML 链接不起作用?我在 Eclipse 中没有收到任何错误消息。

这里是 index.html 的开头:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -->
<html>

<head>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="minimum-scale=1.0, width=device-width, user-scalable=no" name="viewport">
<link href="Chapters/hymns-style.css" rel="stylesheet" type="text/css">
<link href="Chapters/style.css" rel="stylesheet" type="text/css">
<title>Husting Pocket Hymnal</title>
</head>
<body style="background-color:#00aaff">

  <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>      
<!--  <script type="text/javascript" charset="utf-8">
        document.addEventListener("deviceready", function() {
            alert('initialized');
    }, true);
  </script>
-->
<div id="content">

<span class="graytitle">Husting Pocket Hymnal</span>


<ul class="pageitem">

    <li class="menu">
        <span class="name"><a href="Chapters/hymns-a.html">Hymns A</a></span>
    </li>

    <li class="menu">
        <span class="name"><a href="Chapters/hymns-b.html">Hymns B</a></span>
    </li>

这是它转到的页面的开头。 ** 所有这些 HTML 链接都有效:**

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport">
<link href="hymns-style.css" rel="stylesheet" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css">
<title>Hymns A</title>
</head>

<body>
<div id="content">

<span class="graytitle">Hymns A</span>

<br>
<ul class="pageitem">

    <li class="menu">
        <span class="name"><a href="0300.html">
A debtor to mercy alone
        <span class="detailbutton"></span></span></a>
    </li>

    <li class="menu">
        <span class="name"><a href="0301.html">
A lamp in the night, a song in time of sorrow
        <span class="detailbutton"></span></span></a>
    </li>

【问题讨论】:

    标签: android eclipse cordova


    【解决方案1】:

    试试 ...

    如果可行,那么这可能是 URL 处理在这一行的工作方式的错误/边缘情况:https://github.com/phonegap/phonegap-android/blob/master/framework/src/com/phonegap/DroidGap.java#L1028

    【讨论】:

    • 这种格式也不起作用。我只是使用 HTML/CSS,所以你的链接对我没有任何启发。谢谢!
    【解决方案2】:

    我发现了问题。我可以点击文本并转到链接,但点击单元格上的其他地方不起作用。这是因为我删除了属于最右边的箭头 png。如果 a href 标记包含文本和那个箭头,则链接在整个单元格中都有效。

    【讨论】:

      猜你喜欢
      • 2020-05-31
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      • 2015-06-24
      • 2015-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多