FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

JavaScript Help

 


GameFreak
Hey,
Can somebody help me out here? Here's my problem:
I want to access a JavaScript function when I click on a link. What's the coding for that? Is it this:

Code:

<a href="javascript.void:functionName()">Click Here</a>


Please help me as I am confsed.
Roald
Code:
<a href="javascript: functionName();">Click Here</a>
Kaneda
Roald wrote:
Code:
<a href="javascript: functionName();">Click Here</a>


Please, please, please don't put javascript in the href attribute Smile

Code:
<a href="#" onclick="functionName();">Click here</a>


... or preferably (if applicable), make the href point to an alternate page (and make the event handler return "false" to overrule the href) - for users who have javascript turned off, and users who - like me - like to middle click on links to open them in new windows/tabs. Specifically, there's nothing more annoying than links calling an "open in new window" through href, so when I do exactly what the web author wants me to do (open the link in a new window), I get a blank window with "javascript:functionName()" in my address bar Razz

Code:
<a href="otherpage.html" onclick="popup('otherpage.html'); return false;">


(We'll skip the lesson on separating content from behaviour for now Wink)
badai
at the href, it's better to put javascript:void() so on old browser, u won't get the hour glass and can continue working/use your cursor/mouse

e.g.

Code:
<a href="javascript:void(0)" onclick="functionName();">Click here</a>
htmlrules
the whole siciety lives on the
[url]onClick=""[/url]
tag but really there is a huge range of other methods to use
[url]onPress
onRelease
onMouseOver
onMouseout
onMouseMove[/url]
those are just to name a few
htmlrules
sorry guys i clicked on url and not code

here is it reposted
the whole siciety lives on the
Code:
onClick=""

tag but really there is a huge range of other methods to use
Code:
onPress
onRelease
onMouseOver
onMouseout
onMouseMove

those are just to name a few
Ranfaroth
Kaneda is prefectly right.
Read point 3 of this article..
If you care about very old browsers, just use another element without href attribute, like for instance <button> or simply <span> Rolling Eyes
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.