Utilizing the javascript extension (known as window.external) in IE8 (or any IE version) to expose specific functions, I encountered an issue when attempting to call the apply function. Despite the belief that it is inherently available in every JS function, the browser consistently throws an exception stating that the apply function is not present for that function within the window.external object.
For instance, the following code functions correctly:
function onDataReceived(url, success, status, data, errorMessage) {
alert(onDataReceived);
}
function innerTest() {
alert(arguments[0] + ", " + arguments[1]);
}
function outerTest() {
innerTest.apply(null, arguments);
}
outerTest("hello", "world");
// alerts "hello, world"
However, the subsequent code triggers an exception:
function outerTest() {
window.external.innerTest.apply(null, arguments); // <-- exception
}
outerTest("hello", "world");
The main challenge lies in passing an unknown number of arguments to the external function, leading to a roadblock in my progress.
Any suggestions or insights would be greatly appreciated.
EDIT:
After accepting Mike Samuel's response, I realized that the apply
function is not present in the window.external
object, presumably due to it not being a native javascript object. As a temporary solution, I followed Mike's advice on the "worst case" scenario. Thank you.