SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I navigate to a particular anchor point in a page while passing a query string

    How do I navigate to a particular anchor point in a page while passing a query string?

    This doesn't work: <a href="index.php?page=videos&video=dread#video_2">

    The div that contains the dread video look like this:

    <div id="video2" class="video_container" name="video_2">

    The div is way down the page so I don't want people to have to scroll all the way back down to the video container every time they choose a new video to watch.

    Incidentally, is this why we have to scroll all the way back down the Facebook home/news feed every time we're done viewing somebody's link that they posted?

  2. #2
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try

    Code:
     
    <a href="targetPage.php#video2?page=something&video=somethingElse" />
    where video2 is the id and not the name of the target element in targetPage.php

  3. #3
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    930
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by orangedog1984 View Post
    This doesn't work: <a href="index.php?page=videos&video=dread#video_2">

    The div that contains the dread video look like this:

    <div id="video2" class="video_container" name="video_2">
    Remove the name attribute because it is not valid for div tags. Change id="video2" to id="video_2" and it will work. Kalon's suggestion is not right: the anchor point is always specified at the end of the URL regardless of the query string.

  4. #4
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Lemon Juice View Post
    Kalon's suggestion is not right: the anchor point is always specified at the end of the URL regardless of the query string.
    OOOooopppsss......

    I wasn't sure which way it was - looks like I zigged when I should have zagged

    Code:
    <a href="targetPage.php?page=something&video=somethingElse#video2" />


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
  •