473,378 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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



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
1 1544
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: zmcelrath87 | last post by:
I am having a problem involving the scope of timeouts and intervals. Since timeouts and intervals execute in the global scope, dynamically generated local interval/timeout declarations do not work,...
26
by: Patient Guy | last post by:
The code below shows the familiar way of restricting a function to be a method of a constructed object: function aConstructor(arg) { if (typeof(arg) == "undefined") return (null);...
5
by: reycri | last post by:
Hi, I need to be able to do this: var func = new Function("var me = <selfRef>; alert(me.params);"); func.params = "This is a test parameter"; window.setTimeout(func, 500); Basically, I...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.