Adding a Hand Link to onclick behavior

G

Gurlonthesun

How to I change my cursor to a "Hand" for a window link with onclick
behavior? I need people to know that they can click a certain spot for a
popup window to open, and I don't want to have to write "Click here for....."
on my webpage.
 
S

Steve Easton

Is the link an image??

<style type="text/css">
img{
cursor: hand;
}
</style>

Will work in IE, questionable in other browsers.


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed..................
...............................with a computer
 
M

Murray

That's a bludgeon.

If the link is correctly applied, you won't need it.

Let's see the code - I'm betting that the link has been applied to a <div>
or a <font> or a <p> or something goofy like that.
 
S

Steve Easton

Murray said:
That's a bludgeon.

Curious as to why you say that? It's valid CSS according to W3C

If the link is correctly applied, you won't need it.

I believe it's not a link, per say, but an onclick.
I was trying to determine if the clickable object is an image or text or whatever.

Let's see the code - I'm betting that the link has been applied to a <div>
or a <font> or a <p> or something goofy like that.

Yep.

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed..................
...............................with a computer
 
M

Murray

Events go on anchor tags. They are legal on other elements but sometimes
poorly supported or partially supported. To get the 'finger' it needs to be
a link. It doesn't need to look like one, or be one even, e.g.,

<a href="javascript:;" onClick="alert('ouch')">whatever</a>

That will give a pointer.

<p onClick="alert('ewww')">whatever</p>

That will not.
 
M

Murray

Yes, but if you don't need to use it, then don't use it. And this poster
doesn't.
 
G

Gurlonthesun

Sorry for the multiple postings of this question, but when I posted before I
forgot to check the Notify me box, and no matter how hard I searched I could
NOT find my original postings....
Anyway, this is not for an image. It is for a popup window opened with
onclick behavior. I realize that I can create a hyper link to a new window
and get a "hand" but I don't want/need a full window, and the popup one works
great for my purposes. The only problem is that people need to know where to
click, and unless I specify "Click here for directions" (which I have now and
think looks HORRID) no one is ever going to know to do it. Here is the code
I have for the window....

<u onclick="FP_openNewWindow('400', '400', false, false, false, false,
false, false, 'Directions', /*href*/'Directions.htm')">
Click Here For Directions To Our Offices</u></font></div>

Also, is there a way to add a "Print this page" code to the window as well?
I have a Close Window link on there, but can not figure out how to do a print
one.

Dawn
 
M

Murray

You have applied the event to a <u> tag, which is not going to work
reliably, not going to validate, and is just unethical! 8)

Change that code to this -

<a id="special" href="Directions.htm" target="_blank"
onclick="FP_openNewWindow('400', '400', false, false, false, false, false,
false, 'Directions', /*href*/'Directions.htm');return false">Click Here For
Directions To Our Offices</a></font></div>

and with this CSS -

a#special { text-decoration:underline; }

you will get exactly what you want, in addition to having a link that works
even when javascript is disabled (your originaly invalid construction would
not have).
 
G

Gurlonthesun

Weird...that is the code that was put in using the behavior from
Frontpage....why would it be written like that if it wasn't going to work
properly?

Anyway, your solution worked GREAT!!! I have my hand and my little popup
window, so thank you very much!!

Can you tell me how to put a "Print This Page" link in the window? Or a
little printer icon?

Dawn
 
M

Murray

Weird...that is the code that was put in using the behavior from
Frontpage....why would it be written like that if it wasn't going to work
properly?

Anyway, your solution worked GREAT!!! I have my hand and my little popup
window, so thank you very much!!

You're welcome. The lesson here is - anytime you do NOT get the pointer,
check your code. It means you have applied the event to something that the
browser doesn't expect to have events applied to.
Can you tell me how to put a "Print This Page" link in the window? Or a
little printer icon?

All programatic print functions will fail on IE5/Mac, so here is the best
you can do -

Put this in the head of the document -

<script type="text/javascript">
function print_page(where){
var is_mac=(navigator.platform.indexOf("ac") != -1);
(document.all && is_mac)?
alert("Select \"Print\" from the menu") : where? where.window.print() :
window.print();
}

function writeOutPrintLink(){
document.getElementById('printLink').innerHTML = '<a
href="javascript:print_page();">Print this</a>'

}

</script>

Adjust the body tag of the document as follows -

<body ... onload="writeOutPrintLink();"> (where the ellipsis indicates
already existing attributes, if any)
<span id="printLink"></span>

That way, the link only shows up if you have javascript enabled.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top