简体   繁体   中英

Displaying a page in an unordered list through a url string

I have an unordered list that provides navigation for a series of pages that aren't displayed until the user makes a selection. I want to navigate to a specific page and have it display without any user interaction through a url string.

How can I do this?

Here is a code sample;

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

It sounds like you'll want to look into hash tagging.

The idea is you use the window.location.hash (everything after the "#" in the URL) to do navigation. You'll need to make it so when someone clicks on a page link it updates the hashtag to be for that page, and make it so in the initial page load, if there is a hashtag set then you'll need to 'navigate' to that page.

jQuery has a plugin built for this purpose: http://benalman.com/projects/jquery-hashchange-plugin/

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