Web Analytics Made Easy -
StatCounter location.href='#img' with dynamic page - CodingForum

Announcement

Collapse
No announcement yet.

location.href='#img' with dynamic page

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

  • location.href='#img' with dynamic page

    Hi , I have a page that displays an image from a gallery , the image is displayed a way down the page and I want the page to automatically jump to the imgae ... normally I would go blah.com/gallery.htm#img with a matching <a name="img">anchor

    but the pages have search engine friendly urls such as..

    domain.com/gallery.htm/1/2

    where '1' & '2' are respectively gallery and image id's and gathered via PATH_INFO , the page displayed is still gallery.htm .

    I tried adding this to the output..

    PHP Code:
    <?
    //prints the <img src="etc  string to the page
    $rets $this->display_image(  $_REQUEST['fpa_gal_img'] ) ;
    $rets .='<a name="fpa_gal_img"></a>' ;
    $rets .= '<script>location.href=\'#fpa_gal_img\'</script>' ;
    ?>
    and variations of , but the page never jumps anywhere (though works with normal urls.

    Any javascript/whatever solution that anyone can think of ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #2
    ok muppet alert , I obviously did not try all combinations as ...

    <a name="fpa_gal_img"></a>
    <img src="//etc" />
    <script>location.href='#fpa_gal_img'</script>

    seems to work (at least in IE too scared to look in moz)
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

    Comment


    • #3
      try:

      location.href=location.pathname+'#fpa_gal_img';

      or

      location.href=location.href+'#fpa_gal_img';

      if that doesn't work, try focusing to the nearest link or field instead.
      Glenn
      vBulletin Mods That Rock!

      Comment

      Working...
      X