SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    London
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    page refreshing issue

    Hi

    here's a few lines of code I've got in a page that has a php database query in it and I want it to arrive at the anchor link I have called "bottom each time"

    Code:
    <head>
    
    <script language="javascript">
    
    function loadPage()
      {    
    	location.href = "http://wwwmysite.com/help/chat/chat_window.php?theID=<?php echo $id; ?>#bottom";    
      }
    
    </script>
    
    
    </head>
    
    <body bgcolor="#CCCCCC" onLoad="setTimeout('loadPage()',20000)">
    The page reloads fine and brings in the php variable "theID" but it doesn't arrive at the anchor "bottom"........The page does have have data in it to induce scrollbars.

    Is there something I'm doing wrong?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    Get vars and location anchor

    Sorry if I'm not much help.
    I tried something similar a while back and didn't figure out how do do it. Not that it neccessarily can't be done. I just couldn't figure out the syntax for using both a get var and a location anchor in 1 URL.
    If you try
    location.href = "http://wwwmysite.com/help/chat/chat_window.php#bottom";
    it works, right?
    I seem to remember also trying
    location.href = "http://wwwmysite.com/help/chat/chat_window.php#bottom?theID=<?php echo $id; ?>";
    wihout any luck.
    Hopefully someone can share their knowledge of how to do this.

  3. #3
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the problem is you're trying to change courses in the middle of the (data) stream. # and ? are switches. Think of it like a rail yard. If you send the train down track A, you can't suddenly change the switch and send the caboose down track B. Everything that follows a # is an anchor target; everything that follows a ? is GET data. No exceptions.

    I'd suggest separating the two operations or appending the anchor data as GET data and parsing it out to produce an anchor-targeted URL.
    Last edited by JVLB; Sep 5, 2006 at 07:12.


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
  •