Beginner question on Javascript link in PHP

They have: 5 posts

Joined: May 2009

Don't beat me up too much, as I am brand new. We have added images in our index.php, which are called via the following command - all works fine and they link fine. The problem is that the mouse does not change to notify the users that these images are clickable. What are we missing here? Anything else, the mouse changes to the little pointing finger, but not on these calls. Example;

<img onClick="javascript:goToMilitia();" src="http://xxx.xxxxxx.xxx/images/mmenu/button9.png" /><br />

Thanks in advance!

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

You can use CSS to change the cursor to the hand:

img {
    cursor:pointer;
}

But the problem with that is every image will have the pointer (which you probably don't want).

Instead you can add a class to your image tag, and use a CSS selector to modify only the images with that class.

Adding the class to your tag:

<img class="clickable" onClick="javascript:goToMilitia();" src="http://xxx.xxxxxx.xxx/images/mmenu/button9.png" /><br />

And your CSS:
img.clickable {
    cursor:pointer;
}

He has: 629 posts

Joined: May 2007

Better yet, put a real link around the image and scrap the JavaScript. This will do everything you need on all computers, not just those with JavaScript enabled. (Google will find the link, too.)

Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.