SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,531
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Going to specific spot on page

    I am building an "Add a Comment" section at the end of each article page I write.

    The articles usually are several pages long.

    Once a user logs-in/registers, how can I bring them back to where the Comments section is at the bottom of the page?

    (I want them to be able to instantly add a comment and not have to scroll.)

    Thanks,


    Debbie

  2. #2
    Chive On FFCus's Avatar
    Join Date
    Feb 2006
    Location
    Connecticut
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you pass the page number and anchor name in the query string during the log in process and then redirect the user to the page in the querystring after a successful log in?

    When they try to comment but are not logged in:
    Code:
    <a href="login.php?returnurl=article7.php#comment">Login to Comment</a>
    So after they log in, you would just need to redirect them to "article7.php#comment"

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,531
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FFCus View Post
    Can you pass the page number and anchor name in the query string during the log in process and then redirect the user to the page in the querystring after a successful log in?

    When they try to comment but are not logged in:
    Code:
    <a href="login.php?returnurl=article7.php#comment">Login to Comment</a>
    So after they log in, you would just need to redirect them to "article7.php#comment"
    Well, the way I am doing it is this... (Even though this is PHP)

    - User lands on "article1234.php"
    - System sets SESSION with page's filename and path
    - User either logs in or registers
    - On Log-In page, the page accesses the article's filename/path and redirects them there.

    Back to my question...

    So I need an HTML anchor to do what I want as far as scrolling down?

    What the HTML to do that?

    Maybe I can append whatever to my Session variable?


    Debbie

  4. #4
    Chive On FFCus's Avatar
    Join Date
    Feb 2006
    Location
    Connecticut
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So you already had the hard part worked out

    Place an anchor at the spot on the page that the Comments section starts.
    Code:
    <a name="comment"></a>
    Then if you redirect your user to "article1234.php#comment" you will be right there.

    Here is the w3schools area to tinker with
    Tryit Editor v1.4

  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,531
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FFCus View Post
    So you already had the hard part worked out

    Place an anchor at the spot on the page that the Comments section starts.
    Code:
    <a name="comment"></a>
    Then if you redirect your user to "article1234.php#comment" you will be right there.

    Here is the w3schools area to tinker with
    Tryit Editor v1.4
    Okay, thanks!


    Debbie

  6. #6
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    You can also target ID's the same way, so rather than stuffing some pointless empty anchor in there, put an ID on the element you want and then target it just like you would name.

  7. #7
    Chive On FFCus's Avatar
    Join Date
    Feb 2006
    Location
    Connecticut
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    You can also target ID's the same way, so rather than stuffing some pointless empty anchor in there, put an ID on the element you want and then target it just like you would name.
    Good point!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •