56 users online (1 members and 55 guests)  


Page 1 of 2 1 2 Last
  Results 1 to 15 of 19

Related

  1. Replies: 9
  2. How to Pass Dynamic values in Anchor    Forum: HTML Forum
    Replies: 4
  3. Meta Tag with anchor    Forum: HTML Forum
    Replies: 12
  4. anchor links?    Forum: HTML Forum
    Replies: 2
  1. #1
    spatter's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    13

    Question Meta Tag with anchor

    I've built a lame little chat window using php, but that's not really much of an issue.

    Here's what I'm trying to do. I'd like a page to auto-refresh every 15 seconds and immediately load to the bottom of the page (so you can see the last message posted).

    Here's what I've tried. If I use this META tag <META HTTP-EQUIV="refresh" CONTENT="15; URL=message.php"> it will reload perfectly every 15 seconds. But I want it to jump to the bottom of the page.... so....

    I added this anchor tag, <a name="btm">, to the bottom of the page and changed the META tag to <META HTTP-EQUIV="refresh" CONTENT="15; URL=message.php#btm">

    That has a problem though. When I load the page, it recognizes the tag and after 15 seconds, it reloads the page and moves the view correctly to the anchor tag. But then it stops. It doesn't reload again.

    My guess is that when the URL of the current page is message.php it recognizes the META tag, but when the URL is message.php#btm it doesn't read the META tag.

    Any help would be appreciated.
    Thanks,
    Spatter

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hello, welcome to the forums.

    You could try using a javascript method called setInterval, try putting this code in your <head> -

    Code:
    <script language="JavaScript" type="text/javascript">
    function RefreshMe() {
    bob=location.href;
    location.href=bob;
    }
    setInterval("RefreshMe()",15000);
    </script>
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    spatter's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    13
    I'm not great with JavaScript, so I don't quite follow your code.

    bob=location.href;
    location.href=bob;

    What does 'bob' represent? And if you set 'bob' equal to location.href, then it doesn't seem like the second line would be needed.... since they are now equal anyway.

    Please elaborate on this.

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Sorry, Its my wierd way of refreshing my page.

    works like this -

    bob is just a variable

    bob=location.href means that bob=www.quietdean.com for example.

    now we tell the window to change its location to.. bob. in other words, reload the same page.

    if you replace bob with something like thisPageLocation or similar, it makes more sense
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    to explain, in javascript, (and most languages) you assign the second value to the first value. But if you assign to something like location.href it means it will actually change the window location.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  6. #6
    spatter's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    13
    Outstanding. I changed it to

    bob="message.php#btm";
    location.href=bob;

    and it's working like a champ.

    Thanks a bunch,
    Spatter

  7. #7
    spatter's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    13
    oh no... wait. it still has a problem.

    It APPEARS to be refreshing the page. If I scroll up to the top, then after the few seconds it will jump back down to the bottom, but it isn't properly refreshing the content.

    I think the page isn't refreshing, it's just jumping to the bottom.

    Any ideas?

  8. #8
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    try

    *removed* this wont work, see below
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  9. #9
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    also, try adding this to the head

    Code:
    <!-- no cache headers -->
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <!-- end no cache headers -->
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  10. #10
    spatter's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    13
    Didn't work. I did some searching for javascript refreshing techniques and I found this call:

    window.location.reload( true );

    which works for javascript 1.2. Passing "true" will tell it to refresh content from the server-side, which is what I need, since it is php. "False" will refresh on the client-side... which is the same as what you gave me.

    But now I'm back to the problem of jumping to the bottom of the page. This new call doesn't realize that I want it to jump to the anchor.

  11. #11
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hmm.

    If it starts off without the #btn, then it wont work. How about if we start off with the #btn in the url? Will it refresh including the #btn then? If that works, you just have to make sure you always include the #btn in any links.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  12. #12
    spatter's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    13
    Actually, the message.php page is being loaded as a frame within the index.html file. The index file contains:

    <frame src="message.php#btm" name="middle">

    But it appears that the JavaScript call window.location.reload( true ); cuts off the #btm when it does the reload.

  13. #13
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    moving to scripts.
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  14. #14
    spatter's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    13
    Is there a seperate Javascript command for moving the view to the bottom that I could use each time the page loads?

  15. #15
    spatter's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    13
    I see the scrollto(x, y) function. But all the examples I see are for scrolling back to the top. How would you go about finding the maximum y value you can use in the scrollto function?... such that it'll scroll to the furthest down.



Page 1 of 2 1 2 Last

Tags for this Thread