簡體   English   中英

通過url字符串顯示無序列表中的頁面

[英]Displaying a page in an unordered list through a url string

我有一個無序列表,它提供了一系列頁面的導航,這些頁面直到用戶做出選擇才顯示。 我想導航到特定頁面並顯示它,而無需用戶通過url字符串進行任何交互。

我怎樣才能做到這一點?

這是一個代碼示例;

     <!-- Beginning of Show/Hide Functionality -->
        <script>
$(document).ready(function(){

    $("form").hide();

  $("#show").click(function(){
    $("form").show();
$("button").hide();
  });
});
</script>
        <!-- End of Show/Hide Functionality -->
        <!--[if lt IE 7]><script type="text/javascript" src="http://info.template-help.com/files/ie6_warning/ie6_script_other.js"></script>
        <![endif]-->
        <!--[if lt IE 9]><script src="js/html5.js" type="text/javascript"></script>
        <![endif]-->
        <!--[if IE]><link href="css/ie_style.css" rel="stylesheet" type="text/css" /><![endif]-->
        <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <div id="main">
        <ul class="pags">
            <li class="current"><a href="#" rel="1"></a> </li>
            <li><a href="#" rel="2"></a> </li>
            <li><a href="#" rel="3"></a> </li>
            <li><a href="#" rel="4"></a> </li>
            <li><a href="#" rel="5"></a> </li>
        </ul>
        <!-- header -->
        <header class="hidden">
        <div class="extra-wrap" style="left: 0px; top: 0px; right: 0px; bottom: 0px; position: absolute;">
        <h1><a href="#"><img alt="" src="images/logo.png" /></a></h1>
        <nav>
        <ul>
            <li class="itm1"><a href="#page1"></a> </li>
            <li class="itm2"><a href="#page3"></a> </li>
            <li class="itm3"><a href="#page2"></a> </li>
            <li class="itm4"><a href="#page4"></a> </li>
            <li class="itm5"><a href="#page5"></a> </li>
        </ul>
        </nav>
        <a href="#1" class="shattle"></a></div>
        </header>
        <!-- content -->
        <div class="wrapper">
        {tag_pagecontent}
        </div>
        <strong>
        <!-- footer -->

聽起來您會想要研究哈希標記。

這個想法是您使用window.location.hash (URL中“#”之后的所有內容)進行導航。 您需要做到這一點,以便當有人單擊頁面鏈接時,它會更新該頁面的主題標簽,並在初始頁面加載時進行更新,如果設置了主題標簽,則需要“導航”到該頁面。

jQuery具有為此目的而構建的插件: http : //benalman.com/projects/jquery-hashchange-plugin/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM