Selecting an item from a drop down which needs compatibility view

Started by hdsouza, December 16, 2014, 06:13:50 PM

Previous topic - Next topic

hdsouza

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

Code (winbatch) Select

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


stanl

There is a Registry Setting

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation
REG_DWORD valeu - MSCompatibilityMode
Enabled - 1
Disabled - 0


hdsouza

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

hdsouza

Anyone know the correct syntax for objEvent as above?

Please help
Thanks

td

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. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

hdsouza

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
Code (winbatch) Select

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

stanl

maybe checked, not check

function check(){     document.getElementById("myCheck").checked=true     }

hdsouza

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