A
Arnaud Diederen
Hello everyone,
I have a little problem with IE6. Imagine I have a webapp that has a
main/root/parent window, in which there is a function (called: executor())
that makes use of the Function.prototype.apply() function to call a
function that is passed as parameter.
The problem is: It works as long as the functions that are being
passed as paramaters come from the same window as the window that
holds the 'executor()' function. A function (toBeExecuted()) coming
from a child window won't be executed, and IE6 will complain saying
"Object expected". Passing both anonymous or named functions will
produce the same error.
It works in Mozilla browsers, but ... is this fundamuntally bad
practice, or is it just one of IE's restrictions?
Thank you for any information!
Best regards,
Arnaud
Here's the sample code, if it can help in any way:
=================== top.html ===================
<html>
<head>
<title>top</title>
</head>
<body>
<script>
window.id = "top";
window.toBeExecuted_currentScope = function (arg) {
alert ("this.id: " + this.id + ", arg: " + arg);
}
window.executor = function (fun, arg) {
alert ("fun: " + fun + "\nfun.apply: " +
fun.apply + "\narg: " + arg);
fun.apply (this, [arg]);
}
</script>
<input type="button"
onclick="executor(toBeExecuted_currentScope, 'Yippee');"
value="Execute (current scope)" />
<input type="button"
onclick="window.open('./child.html','foo');"
value="Child" />
</body>
</html>
=================== child.html ===================
<html>
<head>
<title>child</title>
</head>
<body>
<script>
window.id = "child";
function toBeExecuted_childScope (arg) {
alert ("(You won't see this..) this.id: " + this.id +
", arg: " + arg);
}
</script>
<input type="button"
value="Execute (anonymous fun from this (child) scope)"
onclick="window.opener.executor(function (arg){alert (arg);}, 'Children anon.');" />
<input type="button"
value="Execute (named fun from this (child) scope)"
onclick="window.opener.executor(toBeExecuted_childScope,
'Children named');" />
</body>
</html>
======================================
--
Arnaud DIEDEREN
Software Developer
IONIC Software
Rue de Wallonie, 18 - 4460 Grace-Hollogne - Belgium
Tel: +32.4.3640364 - Fax: +32.4.2534737
mailto:[email protected]
http://www.ionicsoft.com
I have a little problem with IE6. Imagine I have a webapp that has a
main/root/parent window, in which there is a function (called: executor())
that makes use of the Function.prototype.apply() function to call a
function that is passed as parameter.
The problem is: It works as long as the functions that are being
passed as paramaters come from the same window as the window that
holds the 'executor()' function. A function (toBeExecuted()) coming
from a child window won't be executed, and IE6 will complain saying
"Object expected". Passing both anonymous or named functions will
produce the same error.
It works in Mozilla browsers, but ... is this fundamuntally bad
practice, or is it just one of IE's restrictions?
Thank you for any information!
Best regards,
Arnaud
Here's the sample code, if it can help in any way:
=================== top.html ===================
<html>
<head>
<title>top</title>
</head>
<body>
<script>
window.id = "top";
window.toBeExecuted_currentScope = function (arg) {
alert ("this.id: " + this.id + ", arg: " + arg);
}
window.executor = function (fun, arg) {
alert ("fun: " + fun + "\nfun.apply: " +
fun.apply + "\narg: " + arg);
fun.apply (this, [arg]);
}
</script>
<input type="button"
onclick="executor(toBeExecuted_currentScope, 'Yippee');"
value="Execute (current scope)" />
<input type="button"
onclick="window.open('./child.html','foo');"
value="Child" />
</body>
</html>
=================== child.html ===================
<html>
<head>
<title>child</title>
</head>
<body>
<script>
window.id = "child";
function toBeExecuted_childScope (arg) {
alert ("(You won't see this..) this.id: " + this.id +
", arg: " + arg);
}
</script>
<input type="button"
value="Execute (anonymous fun from this (child) scope)"
onclick="window.opener.executor(function (arg){alert (arg);}, 'Children anon.');" />
<input type="button"
value="Execute (named fun from this (child) scope)"
onclick="window.opener.executor(toBeExecuted_childScope,
'Children named');" />
</body>
</html>
======================================
--
Arnaud DIEDEREN
Software Developer
IONIC Software
Rue de Wallonie, 18 - 4460 Grace-Hollogne - Belgium
Tel: +32.4.3640364 - Fax: +32.4.2534737
mailto:[email protected]
http://www.ionicsoft.com