By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,461 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Scope: Executing, a function coming from another window (IE 6)

P: n/a


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_child Scope,
'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:ad@ionicsoft.com
http://www.ionicsoft.com
Jan 9 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
VK

Arnaud Diederen aundro wrote:
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!


That was already asked and answered at:
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/bcadfcbde01a0b77/565e6accfcd8cd1d>

Nothing is changed since then.

Again: it is not good and it is not bad (though theoretically may raise
gc problems for FF if you update frames independently).

It is simply not documented and not promised by anyone. So wherever
however it works - it is the standard.

Jan 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.