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

  • Thread starter Arnaud Diederen
  • Start date
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
 
V

VK

Arnaud said:
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..._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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top