0

我有一个用于制作 jquery 移动网络应用程序的代码。我的目标是只有一页代码可以处理所有页面。

现在我有一个问题,我想查看另一个用户的个人资料。要访问 Web 应用程序上的另一个页面,我使用 #viewuser 标签告诉它我想去哪个页面。所有 # 个页面都在一个名为 feed.php 的文件中。

我想将变量从链接传递到#viewuser 页面。所以在#feed 页面上会有一个链接"feed.php?user=testuser#viewuser",它将转到#viewuser页面并使用 GET 方法输出用户。

该链接不起作用。我试过:feed.php#viewuser?user=testuser feed.php?user=testuser#viewuser

这是我的代码:

<!DOCTYPE html> 
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>15:11 Project Mobile</title>

<link rel="stylesheet" href="css/jquery.mobile-1.3.0.css" />
<script src="js/jquery-1.8.3.js"></script>
<script src="js/jquery.mobile-1.3.0.js"></script>
</head> 
<body> 

<!-- BEGIN PAGE 1 -->
<div data-role="page" id="feed">


    <div data-role="panel" id="mypanel" data-display="overlay">
        <ul data-role="controlgroup">
            <li><a href="#submit" data-role="button">Page Two</a></li>
                    <li><a href="#browse" data-role="button">Page Three</a></li>
            <li><a href="#projects" data-role="button">Page Four</a></li>
        </ul>
    </div>

    <div data-role="header" data-position="fixed" data-theme="c" data-tap-toggle="false" data-id="foo1">
        <a href="#mypanel" data-icon="bars" data-iconpos="notext" data-role="button" data-theme="c" style="background: none;"></a>
        <center><img src="images/logo_app_white.png"></center>
        <a href="#settingspanel" data-role="button" data-icon="gear" data-iconpos="notext" style="background: none;"></a>
    </div>
    <div data-role="content">   



<?
$sql = "SELECT description, city, status, state, country, needsusername, howmanypeopleneeded, howmanypeoplesignedup, needs.orgname, needs.ID, titleofneed, expiredate, datesubmitted, datetime FROM needs INNER JOIN follow ON follow.followname = needs.needsusername WHERE follow.username = '$username' AND needs.status='posted' ORDER BY datesubmitted DESC";


$lookupposts = mysql_query($sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysql_error(), E_USER_ERROR);

while ($frows = mysql_fetch_array($lookupposts)) {
$id = $frows['ID'];
$needsusername = $frows['needsusername'];
$city = $frows['city'];
$state = $frows['state'];
$expiredate = $frows['expiredate'];
$titleofneed = $frows['titleofneed'];
$needsusername = $frows['needsusername'];
$hmpn = $frows['howmanypeopleneeded'];
$hmpsu = $frows['howmanypeoplesignedup'];
$datesubmitted = $frows['datesubmitted'];
$ds = explode("-",$datesubmitted);
$newdatesubmitted = "$ds[1]-$ds[2]-$ds[0]";
$displayds = date("M d, Y", strtotime($datesubmitted));
$completiondate = $frows['completiondate'];
$description = $frows['description'];
$orgname = $frows['orgname'];
$description = nl2br($fdescription);
$orgname = $frows['orgname'];
$typeofneed = $frows['typeofneed'];
$status = $frows['status'];
$country = $frows['country'];

$otherlookupviewuserpic = mysql_query("SELECT * FROM users WHERE username='$needsusername'");
$otherprofilerow = mysql_fetch_assoc($otherlookupviewuserpic);
$otherviewprofilepic = $otherprofilerow['photo'];
if ($otherviewprofilepic == "") {
$othernewviewprofilepic = "images/default.png";
}
else {
$othernewviewprofilepic = $otherviewprofilepic;
}

echo "$titleofneed<br><a href='feed.php?user=$needsusername#viewuser' style='color: #000000;'>$needsusername</a><br>$newdatesubmitted<br><br>---<br><br>";

}


?>



    </div>
    <div data-role="footer" data-position="fixed" data-theme="c" data-tap-toggle="false" data-id="foo1">
        <div data-role="navbar" style="background: #ffffff;">
            <ul>
                <li><a href="#feed" data-role="button" data-iconpos="top" data-icon="custom-feed">My Feed</a></li>
                <li><a href="#submit" data-role="button" data-iconpos="top" data-icon="custom-submit1">Submit</a></li>
                <li><a href="#browse" data-role="button" data-iconpos="top" data-icon="custom-browse">Browse</a></li>
                        <li><a href="#projects" data-role="button" data-iconpos="top" data-icon="custom-projects">Projects</a></li>
            </ul>
        </div><!-- /navbar -->  
    </div>
    <div data-role="panel" id="settingspanel" data-position="right" data-display="overlay">
        <ul data-role="controlgroup">
            <li><a href="#submit" data-role="button">Page Two</a></li>
                    <li><a href="#browse" data-role="button">Page Three</a></li>
            <li><a href="#projects" data-role="button">Page Four</a></li>
            <li><a href="log_out.php" data-role="button">Logout</a></li>
        </ul>
    </div>
</div>

<!-- END PAGE 1 -->

<!-- BEGIN PAGE 6 -->

<div data-role="page" id="viewuser">
    <div data-role="panel" id="mypanel" data-display="overlay">
        <ul data-role="controlgroup">
            <li><a href="#submit" data-role="button">Page 2</a></li>
                    <li><a href="#browse" data-role="button">Page 3</a></li>
            <li><a href="#projects" data-role="button">Page 4</a></li>
        </ul>
    </div>
    <div data-role="header" data-position="fixed" data-theme="c" data-tap-toggle="false" data-id="foo1">
        <a href="#mypanel" data-icon="bars" data-iconpos="notext" data-role="button" data-theme="c" style="background: none;"></a>
        <center><img src="images/logo_app_white.png"></center>
        <a href="#settingspanel" data-role="button" data-icon="gear" data-iconpos="notext" style="background: none;"></a>
    </div>
    <div data-role="content">   


<?
$user = $_GET['user'];

echo "$user";
?>


    </div>
    <div data-role="footer" data-position="fixed" data-theme="c" data-tap-toggle="false" data-id="foo1">
        <div data-role="navbar" style="background: #ffffff;">
            <ul>
                <li><a href="#feed" data-role="button" data-iconpos="top" data-icon="custom-feed">My Feed</a></li>
                <li><a href="#submit" data-role="button" data-iconpos="top" data-icon="custom-submit1">Submit</a></li>
                <li><a href="#browse" data-role="button" data-iconpos="top" data-icon="custom-browse">Browse</a></li>
                        <li><a href="#projects" data-role="button" data-iconpos="top" data-icon="custom-projects">Projects</a></li>

            </ul>
        </div><!-- /navbar -->  
    </div>

    <div data-role="panel" id="settingspanel" data-position="right" data-display="overlay">
        <ul data-role="controlgroup">
            <li><a href="#submit" data-role="button">Page Two</a></li>
                    <li><a href="#browse" data-role="button">Page Three</a></li>
            <li><a href="#projects" data-role="button">Page Four</a></li>
            <li><a href="log_out.php" data-role="button">Logout</a></li>
        </ul>
    </div>

</div>

<!-- END PAGE 6 -->
4

1 回答 1

0

好吧,一般来说不可能同时使用它们。所以http://www.yourdomain.com/yourpage.php?get=fubar#anchor1在大多数浏览器中都不起作用,所以我们想忘记这一点......

这是一篇我认为会用如何回答你的问题的帖子:http: //www.chrillo.info/2008/02/18/using-anchors-and-get-variables/

基本上将你的锚点变成一个变量,你将不得不重新考虑你的网站是如何工作的,但这将使它完全工作。

于 2013-06-12T20:24:04.797 回答