I need to select an item from a drop down list in IE
The code will not work until I enable countability view option in IE
Count_Select = 3
objEvent = msie.document.createEvent("HTMLEvents") ; needed for compatability mode
MySelect = msie.document.getElementsByTagName("select").item(0)
If objEvent == "" Then ; needed for compatability mode
MySelect.Options.item(Count_Select).selected = @TRUE ; WORKS
Else
objEvent.initEvent("SELECT", @true, @true) ; what is the correct syntax
MySelect.Options.item(Count_Select).dispatchEvent(objEvent) = @true ; what is the correct syntax
EndIf
There is a Registry Setting
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation
REG_DWORD valeu - MSCompatibilityMode
Enabled - 1
Disabled - 0
Quote from: stanl on December 17, 2014, 07:11:59 AM
There is a Registry Setting
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation
REG_DWORD valeu - MSCompatibilityMode
Enabled - 1
Disabled - 0
Hi Stan, The registry change does not appear to be working in IE 11. I also added the REG_DWORD manually in. No luck
Anyone know the correct syntax for objEvent as above?
Please help
Thanks
Try using 'check' instead of "SELECT" in initEvent. The events are defined by input, i.e. mouse 'click', and not type of element. Also don't see a reason for the '= @true' on the last line.
Quote from: td on December 19, 2014, 02:55:58 PM
Try using 'check' instead of "SELECT" in initEvent. The events are defined by input, i.e. mouse 'click', and not type of element. Also don't see a reason for the '= @true' on the last line.
Not sure what you mean by "The events are defined by input"
I tried this and no luck
Count_Select = 3
objEvent = msie.document.createEvent("HTMLEvents")
MySelect = msie.document.getElementsByTagName("select").item(0)
If objEvent == "" Then ; needed for compatability mode
MySelect.Options.item(Count_Select).selected = @TRUE ; WORKS
Else
objEvent.initEvent("check", @true, @true)
MySelect.Options.item(Count_Select).dispatchEvent(objEvent)
EndIf
maybe checked, not check
function check(){ document.getElementById("myCheck").checked=true }
Quote from: stanl on December 20, 2014, 08:31:49 AM
maybe checked, not check
function check(){ document.getElementById("myCheck").checked=true }
Stan, I tried objEvent.initEvent("checked", @true, @true) , Unfortunately it does not select the option
I also tried objEvent.initEvent("clicked", @true, @true) .. same result