Announcement

Collapse
No announcement yet.

How to use Named Anchors for within the page navigation?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to use Named Anchors for within the page navigation?

    It would be really nice on long pages, particularly FAQ pages, to be able to use named anchors (#) to move to locations on the current page.

    I get a forbidden error when I have tried to do this, and it resolves to a URL like this: www.domain-name.com/mm5/#B

    Are named anchors supported in Miva?

    If they are, how do I code it to look for the anchor on the current page?

    If they are not supported, are there any tricks to use as a work around to be able to have navigation links to move up and down the current page?

    Many thanks,
    Lynne
    Lynne Phelps
    Sy-Klone International
    www.sy-klone.com
    Reduce Costs and Increase Uptime with Air Precleaners for Engines & HVAC

    #2
    Re: How to use Named Anchors for within the page navigation?

    You may need to add the file path to the page before the hash.

    For example, www.alphabetsigns.com/s/FAQ/#quest11

    If this doesn't work, check if your mod/rewrite is causing any errors.
    http://www.alphabetsigns.com/

    Comment


      #3
      Re: How to use Named Anchors for within the page navigation?

      Lynne,

      Yes, named anchors are permitted and yes, I've done exactly the same thing for the FAQ pages on my site (www.premierpersonalization.com). Look under "Customer Service" and then "Frequently Asked Questions".

      I created a new page template to be used for just FAQs and then created several "products" for each of the FAQ categories I wanted (account FAQ, Design FAQ, product FAQ, etc). In my navbar, I manually adjusted the page displayed to my FAQ page template rather than the standard PROD template.

      In my FAQ template, I have a standard top anchor:
      Code:
      <a name="Top">
      In each of my FAQ "products" I have the following to go back to that anchor:
      Code:
      <a href="merchant.mvc?Screen=FAQ&Product_Code=FAQ-PhotoDesign#Top">
      (note that the product code in red changes for each FAQ "product")
      Steve

      www.premierpersonalization.com

      Comment


        #4
        Re: How to use Named Anchors for within the page navigation?

        I ran into this problem just a week or two ago. The problem with including a complete URL in the link is that it makes the browser redraw the entire page. Normal in-page links, such as
        Code:
        <a href="#Top">
        , don't work when there's a BASE tag on the page, which there normally is in Merchant.

        I did a quick Google search, and found a solution using JavaScript. Try this:

        Code:
        <a href="javascript:window.location.hash = 'Top';">Top of page</a>
        Last edited by Kent Multer; 04-22-09, 09:41 AM.
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment


          #5
          Re: How to use Named Anchors for within the page navigation?

          Originally posted by Kent Multer View Post
          I ran into this problem just a week or two ago. The problem with including a complete URL in the link is that it makes the browser redraw the entire page. Normal in-page links, such as
          Code:
          <a href="#Top">
          , don't work when there's a BASE tag on the page, which there normally is in Merchant.

          I did a quick Google search, and found a solution using JavaScript. Try this:

          Code:
          <a href="javascript:window.location.hash = 'Top';">Top of page</a>
          Tried this but it opened a blank page with the word "Top" printed in the upper left hand.

          Anyone else found a solution without having to reload the entire page?
          Korey McWilliams
          Project Director
          _____________________________
          korey usbones dot com
          http://usbones.com

          Comment


            #6
            Re: How to use Named Anchors for within the page navigation?

            The solution I posted back on the 22nd does not reload the page (that I can see).

            I have the #Top anchor in the PAGE template for my FAQ pages and then the calling href in the body of my "product" descriptions.

            The href's go from the questions listed at the top of the page to the specific answer below. The return to top goes back to the top anchor as defined on the page template.
            Steve

            www.premierpersonalization.com

            Comment


              #7
              Re: How to use Named Anchors for within the page navigation?

              Originally posted by Meander View Post
              The solution I posted back on the 22nd does not reload the page (that I can see).

              I have the #Top anchor in the PAGE template for my FAQ pages and then the calling href in the body of my "product" descriptions.

              The href's go from the questions listed at the top of the page to the specific answer below. The return to top goes back to the top anchor as defined on the page template.
              Looks like it's reloading the whole page. Here's the link on your FAQ's:

              premierpersonalization.com/mm5/merchant.mvc?Screen=FAQ&Product_Code=FAQ-Account#Why
              Last edited by Korey; 05-12-09, 07:14 AM.
              Korey McWilliams
              Project Director
              _____________________________
              korey usbones dot com
              http://usbones.com

              Comment


                #8
                Re: How to use Named Anchors for within the page navigation?

                Well then, it must be loading pretty quick!

                I waited until I knew I was in the middle of my flash movie at the top of the screen and then scrolled down and clicked on one of the "Return to top" links. Page went back to the top and the flash movie did not restart from the beginning. So that's why I said it didn't look like the whole page was reloading.
                Steve

                www.premierpersonalization.com

                Comment


                  #9
                  Re: How to use Named Anchors for within the page navigation?

                  It loads quickly because most of the page content is already cached on your local machine.
                  Bruce Golub
                  Phosphor Media - "Your Success is our Business"

                  Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                  phosphormedia.com

                  Comment


                    #10
                    Re: How to use Named Anchors for within the page navigation?

                    I think part of the problem is the basehref being on every CTGY page
                    Code:
                    <base href="&mvt:global:basehref;">
                    There doesn't appear to be a way to override the basehref on a per category basis?
                    Last edited by Korey; 05-12-09, 07:58 AM.
                    Korey McWilliams
                    Project Director
                    _____________________________
                    korey usbones dot com
                    http://usbones.com

                    Comment


                      #11
                      Re: How to use Named Anchors for within the page navigation?

                      Even if you could, you would probably break something else such as image paths which might be relieing on the base ref.

                      If page reloading is really an issue, a better idea would be to use CSS show/hide features. Essentially, you would LOAD all content, and just expose certain parts based on CSS rules.
                      Bruce Golub
                      Phosphor Media - "Your Success is our Business"

                      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                      phosphormedia.com

                      Comment


                        #12
                        Re: How to use Named Anchors for within the page navigation?

                        Bruce,
                        what a great idea, it would look really 'sexy' too!

                        Comment


                          #13
                          Re: How to use Named Anchors for within the page navigation?

                          For some reason when I put in the entire URL it doesn't reload the page. After all that...
                          Korey McWilliams
                          Project Director
                          _____________________________
                          korey usbones dot com
                          http://usbones.com

                          Comment


                            #14
                            Re: How to use Named Anchors for within the page navigation?

                            There are some limitations to the way browsers use anchors that especially impact dynamic pages. The browser keeps track of the page url; any url that is not an exact match causes a refresh.

                            <form> and <base> are contain partial urls and do not contain the complete long version of the URL needed to generate the page.

                            You must use a complete url with all the parameters passed after merchant.mvc. If you use #anchor with any url other than the long version, you will get a page refresh or the wrong page.

                            This is why you can not normally use anchors on pages that result from a form post/get. (e.g. the url does not contain all the parimeters needed to generate the page.)

                            The only way I found to reliable get anchors to work in those conditions is to set a javascript variable

                            <javascript>
                            var pagetop = '(the complete url needed to display the dynamic page with all paramiters)';

                            then force a page refresh during an initilization function.

                            function init() {
                            window.location = pagetop;
                            }

                            Then when each #anchor is clicked, it does NOT get redirected to <base href="some path"> or <form action="some path">
                            Ray Yates
                            "If I have seen further, it is by standing on the shoulders of giants."
                            --- Sir Isaac Newton

                            Comment


                              #15
                              Re: How to use Named Anchors for within the page navigation?

                              I just figured this one out for a new FAQ page that I created. Replace names in all caps with your information:

                              &mvt:global:sessionurl;Store_Code=STORECODE&Screen =SCREENNAME#ANCHORLINKNAME
                              Last edited by srmb; 11-04-09, 07:25 PM.

                              Comment

                              Working...
                              X