Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts

    making an image a link using js

    Very awkward question but is there a built-in js method for using an image as a link (i.e: onclick="space.htm") or will I need to have a javascript and call it?

    if so, what would be a good one?

    It may seem stupid but I cannot simply use <a href..>image</a> due to a script, so i need to make the link onclick
    Last edited by canadianjameson; 08-20-2007 at 08:21 PM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by canadianjameson View Post
    It may seem stupid but I cannot simply use <a href..>image</a> due to a script, so i need to make the link onclick
    But what does that script do to your image? can you detail a little bit?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    The script fades it and does all other manner of coolness

    www.enviromark.ca/head/

    i have to change my page to use server-side includes, so i'm no longer calling the dynamic ajax loader I was using to load my content into a central div... which means that my onclick calls to the ajax script are no longer opening the page and i need an equivalent way using onclick.

    You can see what the script does, if you wish to sift through Vic's code, here
    www.enviromark.ca/head/js/effects/FadeImages.js
    and
    www.enviromark.ca/head/js/effects/Animator.js

    the long and short of it is that i need to create the link onclick and not using <a>. How can I do that?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    an idea is to give your JS included files an absolute url... but that will slow the site... What kind of includes do you use?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    right now I'm just using this (for ex):
    Code:
    	<!--#include file="includes/topBar.htm" -->
    i literally found out that I had to use Includes like... an hour ago.

    hehe, so yea, what is the js version of target="_self" (or is there one?)

    could i simply use onclick="this.href('newPage.htm')" or something of the sort?
    Last edited by canadianjameson; 08-20-2007 at 09:40 PM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #6
    Regular Coder kosstr12's Avatar
    Join Date
    Apr 2007
    Location
    Woodstock, Georgia
    Posts
    428
    Thanks
    7
    Thanked 5 Times in 5 Posts
    If you were using onlclick...wouldn't you also need to use functions?

  • #7
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    yes, so I'm asking what the function is to open up a url in the current window via javascript instead of using the <a> tag. in html its <a href="blah.html" target="_self">link</a>

    I figured that this would be an easy one
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #8
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    location.href='http://yahoo.com'

    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •