If you need to pass arguments, then you'll need to set up what's
called a closure. Essentially, this is a function that returns a
function. Something like this:
function myClosure(arg0, arg1, arg2){
return function(){
// in the function that is returned, arg0, arg1, and arg2 are
already established,
// so even though it's not receiving the argument directly, it
knows what the
// argument is
}
}
Then you can call addEvent(el, 'click', myClosure(arg0, arg1, arg2));
Jeremy R. Geerdes
Effective website design & development
Des Moines, IA
For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
[email protected]
Unless otherwise noted, any price quotes contained within this
communication are given in US dollars.
If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!
And check out my blog, Adventures in Web Development, at
http://jgeerdes.blogspot.com
!
On May 25, 2009, at 7:00 PM, Feivi wrote:
>
> ok, my mistake. It IS working in IE, but my problem was that
> attachEvent doesn't allow you to pass variables. Still working on a
> solution...
>
> On May 25, 6:42 pm, Feivi <[email protected]> wrote:
>> I got excited too early, unfortunately. Your solution works perfectly
>> with Firefox, but doesn't work with IE :-(. Any ideas?
>>
>> On May 20, 4:35 pm, Feivi <[email protected]> wrote:
>>
>>> Wow, Jeremy, that's just...Wow! Thanks, it's working great!
>>
>>> On May 20, 1:53 pm, Jeremy Geerdes <[email protected]> wrote:
>>
>>>> Write a function like this:
>>
>>>> functionaddEvent(el,event,method){
>>>> if(el.addEventListener){el.addEventListener(event,method,0)}
>>>> else if(el.attachEvent){el.attachEvent('on'+event,method)}
>>>> else{
>>>> var x=el['on'+event];
>>>> if(typeof(x)=='function'){el['on'+event]=function()
>>>> {x();method()}}
>>>> else{el['on'+event]=method}
>>>> }
>>
>>>> }
>>
>>>> Then you can calladdEvent(theElementYouWant, theEventToListenFor,
>>>> theFunctionToUse);
>>
>>>> Make sure that you don't send the 'on' part of the event name;
>>>> it'll
>>>> automatically add that for you.
>>
>>>> Jeremy R. Geerdes
>>>> Effective website design & development
>>>> Des Moines, IA
>>
>>>> For more information or a project quote:http://jgeerdes.home.mchsi.comhttp
>>>> ://jgeerdes.blogspot.comhttp://jgee...
>>>> [email protected]
>>
>>>> Unless otherwise noted, any price quotes contained within this
>>>> communication are given in US dollars.
>>
>>>> If you're in the Des Moines, IA, area, check out Debra Heights
>>>> Wesleyan Church!
>>
>>>> And check out my blog, Adventures in Web Development,
>>>> athttp://jgeerdes.blogspot.com
>>>> !
>>
>>>> On May 20, 2009, at 12:30 PM, Feivi wrote:
>>
>>>>> Hi,
>>
>>>>> I'm trying to add an onclick function to the gsc-cursor.page
>>>>> elements.
>>>>> I've managed to do it by looping and getting an array of them. The
>>>>> only problem is that adding the onclick stops the gsc-cursor-
>>>>> page from
>>>>> going to the next page!! It seems that a different, unseen
>>>>> onclick is
>>>>> already added by Google which makes the pagination work. Is
>>>>> there any
>>>>> way I can add another function to that? The way I see it as being
>>>>> possible is either
>>
>>>>> 1) somehow dynamically adding a function to the already existing
>>>>> onclick. Don't know if that's possible.
>>
>>>>> 2) If I'd know the name of the function being called by the
>>>>> onclick, I
>>>>> could include that in my own. Is there any way to figure out what
>>>>> function is currently being called?
>>
>>>>> Thanks in advance!
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---