browser "execute" script
Posted: Thu Jun 13, 2013 11:22 am
Hello everyone,
I'm trying to send a keydown (the spacebar, 'n', or whatever) to the iOS browser. So I use iPhoneControlCreate to make my browser. Into this I have a URL of a page which is waiting for one of the aforementioned keys to be pressed. In this URLs html is a script called 'player.js' with an ID of 'PlayerDemo'. The code does not use the jQuery library. So somehow using JS I need to execute a script on the press of a LC button that triggers a keydown event.
I was led to some code on stackoverflow which goes like this:
http://stackoverflow.com/questions/5964 ... key-events
'n' has a key code of 78, space has a key code of 32. I'm not sure what a mouseclick would be. But how do I get 'iPhoneControlSet "browsername","execute",tMyScript' to work?
Thanks in advance
Sean
225 views in 4 days and no replies. Impressive! I like asking questions that no one else knows the answer to. Helps me see I might be onto something groundbreaking. - seaniepie (added 17-06-13)
I'm trying to send a keydown (the spacebar, 'n', or whatever) to the iOS browser. So I use iPhoneControlCreate to make my browser. Into this I have a URL of a page which is waiting for one of the aforementioned keys to be pressed. In this URLs html is a script called 'player.js' with an ID of 'PlayerDemo'. The code does not use the jQuery library. So somehow using JS I need to execute a script on the press of a LC button that triggers a keydown event.
I was led to some code on stackoverflow which goes like this:
http://stackoverflow.com/questions/5964 ... key-events
Code: Select all
var keyboardEvent = document.createEvent("KeyboardEvent");
var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent";
keyboardEvent[initMethod](
"keydown", // event type : keydown, keyup, keypress
true, // bubbles
true, // cancelable
window, // viewArg: should be window
false, // ctrlKeyArg
false, // altKeyArg
false, // shiftKeyArg
false, // metaKeyArg
40, // keyCodeArg : unsigned long the virtual key code, else 0
0 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0
);
document.dispatchEvent(keyboardEvent);
Thanks in advance
Sean
225 views in 4 days and no replies. Impressive! I like asking questions that no one else knows the answer to. Helps me see I might be onto something groundbreaking. - seaniepie (added 17-06-13)