使用Jquery Mobile时,HTML A HREF会继续添加#和基本url


When Working with Jquery Mobile, HTML A HREF Keeps adding # and base url

好的,

我在这里已经无计可施了。我已经阅读了关于锚标签、基本url和/在a href中的用法的问题。然而,无论我做什么,我似乎仍然会在链接中添加一个锚标签和基本url。

以下示例:当我将鼠标悬停在链接上时,它会显示http://www.localhost:8080/view/login.php但当我点击a href标签时,我会在下面看到这个http://www.localhost:8080/view/register.php#/view/login.php

HTML:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Food Loginator</title>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css">
        <link href="../CSS/main.css" rel="stylesheet" type="text/css">
        <script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript"></script>
        <script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
        <script src="../Javascript/gen_validatorv4.js" type="text/javascript"></script>
        <script src="../Javascript/pwdwidget.js" type="text/javascript"></script>
    </head>
<body>
<div data-role="page" id="home">
    <header data-role="header">
        <h1>Food Loginator</h1>
        <div data-role="navbar">
            <ul>
                <li><a href="http://www.localhost:8080/index.php" data-icon="home" data-theme="b" >Home</a></li>
                <li><a href="http://www.localhost:8080/view/login.php" data-icon="star" data-theme="b" >Login</a></li>
                <li><a href="http://www.localhost:8080/view/register.php" data-icon="grid" data-theme="b" class="ui-btn-active">Register</a></li>
            </ul>
        </div>
</header>

欢迎提出任何想法。

这似乎是JQuery移动功能的默认部分。显然,JQuery对a标记中带有#标记的对象执行Ajax调用。然后它将该对象动态添加到DOM中。为了删除它,我不得不在我的a标签中添加rel="external"。

https://demos.jquerymobile.com/1.2.0/docs/pages/page-links.html

设置链接href='#'

并添加一个使用changePage 的onclick事件调用

function pagechange () {
$.mobile.changePage('index.php');
}