FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


[JS] detecting events on specific targets and doing anything





polarBear
How do I, just with javascript, and without using

<whateverelement onClick="whateveraction"/>

grab the onClick event and validate if it's some specific element, i.e. an image?
clogfan
As far as I know, onclick is the only way to intercept such an event, so you'll have to do it this way.

What do you want to achieve with this ?
Stubru Freak
If you want to execute the onclick without coding it in your element, you could try document.theElement.onclick="";
Not sure if it works but I guess so. Is this what you're looking for?
polarBear
What I want to do is to completely separate content, behavior and styles. To separate styles, you have CSS. To separate behavior, you have to quit using 'onHandler' attributes on your markup; and I want to know how can I do it...
here's a quick scribbling to describe what I mean
Nyizsa
Separating content, behaviour and style is a good way to build pages. However, you need to connect the elements to their behaviours. So keep on using the onHandler attributes, but put your script in a separate file (handlers.js, for example). This way you have separated behaviour from content, AND you can simply use the same scripts in different pages.
I hope it helped.
Stubru Freak
Can't you set the handlers in your script like i said earlier somehow?
document.getElementById("").onClick=...();
polarBear
I just did Razz just realized that I MUST -like in 'no choice here folks'- initialize the functions for them to work. Curiously, at least for IE and Firefox not putting the handling statements in functions doesn't mean that they will be executed anyway. Weird huh?
Related topics
[RESOLVED]Does anyone know how to block a specific site...
[OFFICIAL] World Of Warcraft - No new topics about this
[OFFICIAL] Favorite Anime?
Deism vs Atheism
Is there anything to worry about with GMail?
why did "god" create "satan"
Ways to make hell good?
Is your country on THIS map?
The Science of the Bible
Megaman Phoenix
The nuttiest idea I ever heard
Is nanotechnology immoral?
Principal, Athletic Director Could Face Jail Time For Prayer
Idyllic Constitution V 1.0 - Federated Anarchist Inspired
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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