Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-20-2007, 07:18 PM   PM User | #1
canadianjameson
Senior Coder

 
Join Date: Jul 2003
Location: My pimped-out igloo in Canadia
Posts: 1,966
Thanks: 36
Thanked 0 Times in 0 Posts
canadianjameson is an unknown quantity at this point
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
__________________
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 :)

Last edited by canadianjameson; 08-20-2007 at 07:21 PM..
canadianjameson is offline   Reply With Quote
Old 08-20-2007, 07:33 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
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
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 08-20-2007, 08:02 PM   PM User | #3
canadianjameson
Senior Coder

 
Join Date: Jul 2003
Location: My pimped-out igloo in Canadia
Posts: 1,966
Thanks: 36
Thanked 0 Times in 0 Posts
canadianjameson is an unknown quantity at this point
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 :)
canadianjameson is offline   Reply With Quote
Old 08-20-2007, 08:09 PM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
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
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 08-20-2007, 08:23 PM   PM User | #5
canadianjameson
Senior Coder

 
Join Date: Jul 2003
Location: My pimped-out igloo in Canadia
Posts: 1,966
Thanks: 36
Thanked 0 Times in 0 Posts
canadianjameson is an unknown quantity at this point
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?
__________________
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 :)

Last edited by canadianjameson; 08-20-2007 at 08:40 PM..
canadianjameson is offline   Reply With Quote
Old 08-20-2007, 09:50 PM   PM User | #6
kosstr12
Regular Coder

 
kosstr12's Avatar
 
Join Date: Apr 2007
Location: Woodstock, Georgia
Posts: 428
Thanks: 7
Thanked 5 Times in 5 Posts
kosstr12 is on a distinguished road
If you were using onlclick...wouldn't you also need to use functions?
kosstr12 is offline   Reply With Quote
Old 08-20-2007, 09:59 PM   PM User | #7
canadianjameson
Senior Coder

 
Join Date: Jul 2003
Location: My pimped-out igloo in Canadia
Posts: 1,966
Thanks: 36
Thanked 0 Times in 0 Posts
canadianjameson is an unknown quantity at this point
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 :)
canadianjameson is offline   Reply With Quote
Old 08-20-2007, 10:11 PM   PM User | #8
canadianjameson
Senior Coder

 
Join Date: Jul 2003
Location: My pimped-out igloo in Canadia
Posts: 1,966
Thanks: 36
Thanked 0 Times in 0 Posts
canadianjameson is an unknown quantity at this point
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 :)
canadianjameson is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:54 PM.


Advertisement
Log in to turn off these ads.