View Full Version : making an image a link using js

08-20-2007, 08:18 PM
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

08-20-2007, 08:33 PM
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?

08-20-2007, 09:02 PM
The script fades it and does all other manner of coolness


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

the long and short of it is that i need to create the link onclick and not using <a>. How can I do that?

08-20-2007, 09:09 PM
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?

08-20-2007, 09:23 PM
right now I'm just using this (for ex):

<!--#include file="includes/topBar.htm" -->

i literally found out that I had to use Includes like... an hour ago. :D

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?

08-20-2007, 10:50 PM
If you were using onlclick...wouldn't you also need to use functions?

08-20-2007, 10:59 PM
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 :D

08-20-2007, 11:11 PM