Sorginator Posted September 14, 2019 Share Posted September 14, 2019 Hey guys, I tried to pass an array to a function in the cef, but it failed. Test Code: // Javascript let array = ["Test1", "Test2"]; mp.keys.bind(0x59, true, function() { browser = mp.browsers.new("package://test/cef/index.html"); browser.execute('testFunc("' + array + '")'); }); //CEF function testFunc(testArray) { var testDiv = document.createElement("div"); testDiv.className='tttTt'; testDiv.id = "testDiv1"; testDiv.innerText = testArray[0]; } I've also tried the following code: // Javascript let array = ["Test1", "Test2"]; mp.keys.bind(0x59, true, function() { browser = mp.browsers.new("package://test/cef/index.html"); let jsonStrng = JSON.stringify(array); browser.execute('testFunc("' + jsonStrng + '")'); }); //CEF function testFunc(testArrayJSON) { let testArray = JSON.parse(testArrayJSON); var testDiv = document.createElement("div"); testDiv.className='tttTt'; testDiv.id = "testDiv1"; testDiv.innerText = testArray[0]; } Can you tell me what I did wrong or/and how to pass arrays from Javascript to the CEF? Link to comment Share on other sites More sharing options...
MiMIMi Posted September 14, 2019 Share Posted September 14, 2019 Try passing your JSON string in the function like this browser.execute(`testFunc('${jsonString}');`); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now