dooberry Posted April 13, 2006 Share Posted April 13, 2006 Hi guys,I'm having some trouble. I don't want to use a button or an image for what I'm doing so I thought an anchor would solve the problem (except it doesn't). I need some text to trigger a function on my web page when it is clicked. I tries using an anchor without a URL attached to it, but it behaves as normal text and doesn't do anything.my code is: <a onclick="function()">click here for something to happen</a> I assume it's because the anchor is empty. Is there another tag I can use? There is a spoon!!! It's there! I can see it in your hand! No spoon - pah!!!!!Can anyone help please?Dooberry Link to comment Share on other sites More sharing options...
dooberry Posted April 13, 2006 Author Share Posted April 13, 2006 Nope,I lied, it works. Sorry for wasting everyone's time. Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 13, 2006 Share Posted April 13, 2006 Well, next time, to promote cross browser, make sure you have 'java script:' in front of the function. <a onclick="javascript:function()">click here for something to happen</a> Link to comment Share on other sites More sharing options...
Little Goat Posted April 13, 2006 Share Posted April 13, 2006 actually, you can put it in the href:<a href="java script:function()">LG Link to comment Share on other sites More sharing options...
dooberry Posted April 19, 2006 Author Share Posted April 19, 2006 Thanks for the tips, they're always useful.We all know that Billy Gates is taking over the world though so it's only a matter of time before IE is the only browser you can get for your Xbox PC multimedia station complete with integral wallpaper!! :)I'm still a newbie really, just a busy one. Link to comment Share on other sites More sharing options...
Jack McKalling Posted April 19, 2006 Share Posted April 19, 2006 Remember that the anchor does in IE seem to do something it doesn't do in other browsers, so you can also use <span> if you want, which does not do anything at all exept binding some content into one element Link to comment Share on other sites More sharing options...
aspnetguy Posted April 19, 2006 Share Posted April 19, 2006 I like the <a onclick="function()">. I avoid putting it in the href because occasionally IE will barf on this (actually try and find a page called the function name) its weird. Link to comment Share on other sites More sharing options...
Jack McKalling Posted April 19, 2006 Share Posted April 19, 2006 Besides, images won't load after you clicked an anchor untill the next page is loaded.And last, an anchor wo'nt be recognised as so ever by IE, if it hasn't a HREF attribute specified It disables click <span> would be the best sollution I think Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now