VBA IE call a javascript containing 'this' keyword -


i attempting call javascript function on webpage contains 'this' keyword referring <input> textbox on webpage. function looks this:

functiondostuff('hdnattribute',this,'key') 

using

js = "functiondostuff('hdnattribute',this,'key')" call ie.document.parentwindow.execscript(js) 

doesn't throw error not produce results of function since this cannot identified.

stepping through website this = [object disphtmlinputelement] instead of element name while function running. have ideas?

good morning,

adding more issue. there seems 2 problems, 1st setting window.event, functiondostuff begins with: if (window.event && window.event.keycode == 13), when function called exits out due event being null. there way pass event 13 website? second issue submitting "this" htmlinputobject.

does know method fire 'onkeypress' event? @ point of trying sendkeys avoid calling function have not been able them work ie. suggestions!

key point context. if have html

<input onclick="functiondostuff('hdnattribute',this,'key')"> 

then browser can infer context user interaction , set this correctly.

from within vba that's different matter , have define context manually.

how this:

dim js variant  js = array( _     "var input = document.getelementbyid('yourelementsid');", _     "functiondostuff('hdnattribute',input,'key');" _ )  call ie.document.parentwindow.execscript(join(js, vbnewline)) 

this way define context yourself.

document.getelementbyid sake of example. if element has no id, use other method (like dom traversal, document.queryselectorall, document.getelementsbytagname + loop, ...) reference desired element.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -