...

View Full Version : Hopefully an easy question about onClick links.



cameronlanni
10-23-2005, 12:04 AM
Is there a way to have a link that executes a function onClick, but when you mouse over your cursor turns to the pointer finger icon like a regular html link? I have the link system and everything working fine, but people are getting confused because the words don't look like links but they are.

Thanks everyone!

littlehank
10-23-2005, 12:12 AM
<img src="image.bmp"
onmousedown="function here"
onmouseover="function here">
I had a script for cursors, I'll go find it. be right back

littlehank
10-23-2005, 12:17 AM
OK replace function here in the onmouseover event for your img with this:


cursor: url(hand)

I think. If that doesn't work try this:

cursor: (hand)
and if those don't work, try adding .cur after hand.
Hope this helps:)
-littlehank

cameronlanni
10-23-2005, 12:28 AM
I'd hate to say it, but I tried all four of those combinations and it didn't work. Also, I'm not using an image, but that shouldn't matter with the cursor.

littlehank
10-23-2005, 12:31 AM
I found this. maybe if we changed the body or ahover to img or something like that, whatever you're using, it would work...

<style>
body { cursor: url(something.cur); }
a:hover { cursor: url(something.cur); }
</style>
Try it.
-littlehank

cameronlanni
10-23-2005, 12:36 AM
and where you write:

something.cur

what should I write?

littlehank
10-23-2005, 12:38 AM
either:
a - url of a custom cursor
b - hand.cur or whatever the default link cursor is named.

cameronlanni
10-23-2005, 12:40 AM
Wait, I think you may have misunderstood what I'm doing. I'm just making a simple text link:


<a href onClick="justleave()">Just Leave </a>

<script>
function justleave() {

top.document.getElementById("frame1").src="frames/5.htm"

}
</script>

The link and everything works fine, but when you mouse over it, the cursor is just your ordinary cursor like when you mouse over this text. People can't tell it's a link.

littlehank
10-23-2005, 12:41 AM
i don't get it

Pyth007
10-24-2005, 08:18 PM
Took me a while to find the error (such a small thing to overlook)... just have href point somewhere (eg "<a href='#' onClick='myFunction()'>Click Here</a>") Note: href='#' points to itself while href="www.codingforums.com" will point to an actual url.

cameronlanni
10-24-2005, 08:22 PM
Hmmmm. That may have worked. I was able to figure it out with the help of fci, however. See:

<a href="" onClick="gotoplace(); return false;"> Go </a>

The "return false;" tag renders the href potion of the link useless.

arpeggione
11-30-2005, 09:57 PM
Hi: I am using code similar to that below for calling a javascript function from a link.

I am able to call my function in the head and also from an input button. So..the function works well. But the link is eluding me (and of course that is what I need...). I can't seem to render href useless... I've tried:

<a href="" onClick="gotoplace(); return false;"> Go </a>
<a href="#" onClick="gotoplace(); return false;"> Go </a>
<a href="..." onClick="gotoplace(); return false;"> Go </a>

The above solutions seem to work for many of the people on this forum, but not for me (my function does work)...I am wondering - I've got windows XP. Could this be the problem?

thanks to anyone who can offer any help...

karen99

_Aerospace_Eng_
11-30-2005, 10:26 PM
What is your function, you could have an error in it.

arpeggione
11-30-2005, 10:48 PM
To Aerospace:

thanks for your reply....here is my function. I know it works, as i can call it elsewhere and open the file. In addition, I just tried this on a machine with windows 2000 (href=""), and it took me to the directory where the file is...

<script language="Javascript" type="text/javascript">
function startXL(strFile)
{
var myApp = new ActiveXObject("Excel.Application");
if (myApp != null)
{
myApp.visible = true;
myApp.workbooks.open("d:\test.xls");
}
}
</script>

also tried this script:
<script language="Javascript" type="text/javascript">
function startXL(strFile)
{
var myApp = new ActiveXObject("Excel.Application");
if (myApp != null)
{
myApp.visible = true;
myApp.workbooks.open("d:\\test.xls");
}
}
</script>




and for your convenience: the link code I've tried:

<a href="" onClick="startXL(); return false" style="cursor: pointer;">test</a></li>

<a href="#" onClick="startXL(); return false" style="cursor: pointer;">test</a></li>

<a href="..." onClick="startXL(); return false;" style="cursor: pointer;">test</a></li>

_Aerospace_Eng_
11-30-2005, 11:59 PM
Using those links they all work fine for me. I'm not sure why they don't work for you. What are the specs of your system? Is this being ran locally like on an intranet? :confused:

arpeggione
12-01-2005, 06:48 AM
To Aerospace:

thanks again for taking the time to try out my question. I am really stumped... yup, I'm on an Intranet. Do you have winxp or windows2000?

karen99

_Aerospace_Eng_
12-01-2005, 06:50 AM
I have winxp. I wouldn't expect this to be a bug but it could be a setting on your intranet or something, I do know that if its left blank and no return false is added then yes it will open windows explorer.

arpeggione
12-01-2005, 05:57 PM
thanks for your thoughts Aerospace...;) if I crack this one, I'll post on this thread again....

karen99

arpeggione
12-05-2005, 07:38 PM
To Aerospace...

Are you on a large corporate Intranet? I am. I just found something about how onclick links are sometimes disabled on corporate Intranets. I can call my javascript function in other ways - so scripting is not completely disabled. (I checked that too - in Security).

Have you heard of this? thanks again,

arpeggione (I changed my name from karen99)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum