Paul Rogers put some event code on the wiki, I haven't used it but looked at it and it might give you a better approach for js events.
Charley Baker blog: http://blog.charleybaker.org/ Lead Developer, Watir, http://wtr.rubyforge.org QA Architect, Gap Inc Direct On Thu, Mar 12, 2009 at 12:54 PM, <andrew.d...@lthree.com> wrote: > > Yea, I've tried passing it as a parm with no luck also. Everything > says it is supposed to work, but I can't get it. > > On Mar 12, 12:11 pm, Andy Sipe <ajs.gene...@gmail.com> wrote: > > Take a look at this W3 schools link, it may help: > http://www.w3schools.com/jsref/jsref_onkeypress.asp > > > > Note how they pass the event from the link: > > > > onmousedown="getEventTrigger(event)" > > > > vs > > > > onmousedown="getEventTrigger() > > > > Maybe that will help - andy > > > > > > > > > > > > On Thu, Mar 12, 2009 at 1:06 PM, <andrew.d...@lthree.com> wrote: > > > > > Thanks for all your help on this - I wouldn't have gotten this far > > > without it. I have attached to an onclick of a link, and the function > > > is being called. My only remaining issue is a missing 'event' object > > > in the js. This is on ie. Here is the js function being attached to > > > onclick: > > > > > onclick_js = "function(){" > > > onclick_js = " alert('button clicked');" > > > onclick_js += " event = window.event;" > > > onclick_js += " if(event){" > > > onclick_js += " alert('found event');" > > > onclick_js += " } else { " > > > onclick_js += " alert('no event available'); " > > > onclick_js += " }" > > > onclick_js += "}" > > > > > I get the alert 'button clicked' and then 'no event available'. > > > > > Has anyone tried this and/or have any ideas on what to try. (I have > > > tried passing event as a parm to the funcion - no difference). > > > > > In case it helps, here is the code that attaches this js to the > > > onclick. > > > > > js = "var top_frame=document.getElementById('top_frame');" > > > js +="if(top_frame){" > > > js +=" var myelem=top_frame.contentWindow.document.getElementById > > > ('" + html_id + "');" > > > js +=" if(myelem){ " > > > js +=" myelem.onclick=" + onclick_js + ";" > > > js +=" }" > > > js +="};" > > > > > #puts "exec_js is " + js > > > > > SITE.browser.document.parentWindow.execScript(js, "javascript") > > > > > On Mar 11, 1:04 pm, andrew.d...@lthree.com wrote: > > > > <snip>...- Hide quoted text - > > > > - Show quoted text - > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---