Event.observe(window, 'load', function()
{
Event.observe( 'searchBt', 'click', function(e)
{
ajaxListReceiver('{$clientId}');
getWinnerCount(0);
Event.stop(e);
});
});
var phrase = "This is SPAARRTTAAAA!";
$('somelink').observe('click', sayIt.bindAsEventListener(this, phrase));
function sayIt(event, phrase) {
console.log(phrase);
}
phrase = "Red sauce on PAASTAAAA!";
var obj = { name: 'A nice demo' };
function handler(e) {
var tag = Event.element(e).tagName.toLowerCase();
var data = $A(arguments);
data.shift();
alert(this.name + '\nClick on a ' + tag + '\nOther args: ' + data.join(', '));
}
Event.observe(document.body, 'click', handler.bindAsEventListener(obj, 1, 2, 3));
// Now any click on the page displays obj.name, the lower-cased tag name
// of the clicked element, and "1, 2, 3".
/*
* add click event
*
*/
// Attaching events
for (var i = items.length; i--; ) {
Event.observe(items[i], 'click', e_onclick, false);
}
// Detaching events
for (var i = items.length; i--; ) {
Event.stopObserving(items[i], 'click', e_onclick, false);
}
/*
* add click event with "return false"
*
*/
in html file:
Event.observe(window, 'load', function() {
Event.observe('button2', 'click', onchecktime);
});
if js file:
var onchecktime = function(event){
var element = Event.element(event);
alert(Event.pointerX(event));
Event.stop(event); // avoid page reloading
};
没有评论:
发表评论