Welcome to WebDesignForums.net!
You're currently viewing WDF as a guest. By registering for a free account, you'll be able to participate with other members in our friendly community. Being a member allows you to ask questions and get answers for those troublesome web development tasks!

In addition, as a member you'll be able to post your websites up for review. Using our unique website review system you can gain some amazing feedback from some of the best web developers around. This is a completely free service to all registered members.

Ready to register yet? Registration is 100% free. Click Here To Join Now!

page links to itself...

Discussion in 'HTML and CSS Help' started by hagen, Apr 14, 2006.

  1. Offline

    hagen Member

    Message Count:
    376
    Likes Received:
    1
    Trophy Points:
    18
    Hi, I would like a page with a link on it that when I click, it jumps to itself using an html / css link...

    IE somthing like:

    href="."

    I don't want to explicitly declare the file names as i want it to be generic for whatever page i am on...

    and ideas??

    Cheers -Hagen


  2. Offline

    bfsog Coder

    Message Count:
    2,354
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    UK
    Using html and css alone, I do not think so..

    With JavaScript, yes.


  3. Offline

    mlseim WDF Staff

    Message Count:
    5,481
    Likes Received:
    224
    Trophy Points:
    63
    Gender:
    Male
    Location:
    Cottage Grove, Minnesota
    There is a way ... but it's a PHP method.

    That means, you would have to change your extensions from .html to .php

    Inside that HTML file (for example: index.php), you would insert this:

    <?php
    $url=$_SERVER['PHP_SELF'];
    echo "<a href='$url'>Re-display this page</a>";
    ?>


    The link becomes a link to itself ... no matter what the URL is.
    The advantage of PHP of course, is that you could send variables
    back to itself and utilize other PHP sections to process variables.
    Sort of a dynamic, change-on-the-fly type of thing. If anyone
    has Javascripting turned off, it would still work OK.

    =====================

    Doing it with Javascripting?
    http://www.google.com/search?q=javascript reload page&btnG=Search&hl=en&lr=


    .


  4. Offline

    hagen Member

    Message Count:
    376
    Likes Received:
    1
    Trophy Points:
    18
    Yeah, I already did that in the intrium, but I want to know just for record how to do it in css / html...

    Thanks -Hagen


  5. Offline

    Jason Formally Perad

    Message Count:
    855
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Hatfield, England
    I have probably completely misunderstood the question but don't you just need to do href="#" That will take you to the same page


  6. Offline

    bfsog Coder

    Message Count:
    2,354
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    UK
    "#" is just for a dummy link, to call a client side scripting function, or similar.


  7. Offline

    Arkette New Member

    Message Count:
    102
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Europe
    I've got ask this: why if a client is already viewing a page, does he need a link to reload the same page?


  8. Offline

    dchesterton "I'm addicted to WDF"

    Message Count:
    200
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Essex, United Kingdom
    Oh no it isn't href="#" is used for bookmarks actually. E.g.
    Code:
    <div id="content">Content Here</div>
    <p><a href="#content">Go To Content</a></p>
    Just a href="#" will return the user to the top of the page. You could pass a dummy querystring, e.g.
    Code:
    <a href="?a=a">Reload Page</a>
    Although this has the obvious side effect of passing a non-meaningful querystring.

    Javascript Option
    Code:
    <a href="javascript:location.reload(true)">Reload Page</a>
    Hope this is useful :D


Share This Page