SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    Wishful Thinking webmasternovis's Avatar
    Join Date
    Jul 2002
    Location
    England
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Links

    Hi there,

    Would anyone be kind enough to tell me how you make javascript links please?

    Mike

  2. #2
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a script that I wrote (this is probably what you're looking for):

    Code:
    <Script language="JavaScript">
    function goTo(pageName)
    {
    window.location.href = "http://www.yoursite.com/"+pageName+".html";
    }
    </script>
     
    <a href="goTo('page1')">Go to page1.html!</a>
    As you can see, this is a pretty simple script...all you have to do is call the goTo() function and pass the name of the page you want the visitor to be sent to and the JavaScript does the rest.

  3. #3
    SitePoint Addict BenANFA's Avatar
    Join Date
    Apr 2003
    Location
    Bath, UK
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gregc
    Here's a script that I wrote (this is probably what you're looking for):
    Not quite correct I believe you have missed a javascript: in the href as follows

    PHP Code:
    <Script language="JavaScript">
    function goTo(
    pageName)
    {
    window.location.href "[url=http://www.yoursite.com/]http://www.yoursite.com/"+pageName+".html[/url]";
    }
    </script>
     
    <a href="javascript: goTo('page1')">Go to page1.html!</a> 
    Except that of course there should ne no space between java and script.

  4. #4
    Wishful Thinking webmasternovis's Avatar
    Join Date
    Jul 2002
    Location
    England
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

  5. #5
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, heh forgot about the "javascript:". The script is still sound, though.


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
  •