SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with piece of code

    In the following code the user is taken back 4 pages, but is their away I could write this so as it would take the user to a specific page such as home.html istead of just taking them back 4 pages

    PHP Code:
    <script language="javascript">
    function 
    goHome()
    history.go(-4);
    }
    </script> 

  2. #2
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, it's called a 'hyperlink' and it's the basis of the entire web.

    Code:
    <a href="destinationpage.html">Link element</a>
    If for some reason, you *need* to use javascript to reproduce a basic link function:
    Code:
    <script type="text/javascript">
    
    function goTo(url) {
    window.locataion.href=url;
    }
    
    
    ...
    
    <a href="home.html" onclick="goTo(this.href); return false;">Link element</a>
    </script>
    Is there any particular reason you wish to use javascript to reproduce a basic link function?
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


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
  •