SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Simple JS link

  1. #1
    SitePoint Addict aliEn's Avatar
    Join Date
    Oct 2001
    Location
    .au/.sg
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple JS link

    How do I use JavaScript instead of using this " <a target="_blank" href="http://www.OtherWebsites.com">Other websites</a> " if I want to use a list of JavaScript links?

    Thanks!

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    Nottingham - UK
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not quite sure what u mean by that which u have written .. if u want to "mask" your url using javascript then perhaps u should be looking at on mouseover or encoding the url tho I guess u mean something as so:

    Code:
    function link1() {
    document.location.href="url-to-page.html"
    }
    Then in ur html file (assuming the above goes in an external javascript file) u would just put in:

    Code:
    <a href="javascript:link1()>Link1</a>
    OR u could put the whole link into the javascript like so:

    Code:
    function link2() {
    document.write("<a target="_blank" href="http://www.OtherWebsites.com">Other websites</a>")
    }
    Then the html code would be:

    Code:
    <script language="javascript" src="yourjavascript.js"></script>
    Where u want it in your page

    Crusader

  3. #3
    SitePoint Addict aliEn's Avatar
    Join Date
    Oct 2001
    Location
    .au/.sg
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, I'm not trying to mask the URL using mouseover or something. I wanted to use Javascript for my external links to substitute the normal HTML " <a target="_blank" href="http://www.OtherWebsites.com">Other websites</a> ".

  4. #4
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by aliEn
    No, I'm not trying to mask the URL using mouseover or something. I wanted to use Javascript for my external links to substitute the normal HTML " <a target="_blank" href="http://www.OtherWebsites.com">Other websites</a> ".
    Why?
    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
  •