A
Arnaud Diederen
Hi,
[I've checked the archives, found some postings that were more or less
related to my problem, but couldn't find a satisfying answer.]
Let's say I have a webapp 'root' window into which I include all
my important JavaScript, including functions that I use as
constructors. Let's say I have a 'class' whose constructor is
'Konstructor'. (weird name, but it's only for the example)
If, from this root window, I create a new window
(window.open('./subwin.html')), I can access the code of the
constructor (with: window.opener[.top].Konstructor), but I cannot
execute a "new window.opener[.top].Konstructor (args)", because IE
complains about an invalid function call.
(IE has this problem, Mozilla runs the code fine. Other browsers
untested)
Has anyone any idea about this?
What prevents me from doing so?
Is it improper JS?
Any pointer/idea where to look?
Thanks much for any information you could provide
Best regards,
Arnaud
Follows: A test-case that works w/ Mozilla, and fails w/ IE:
==================================================
root.html:
<html>
<head><title>test scope</title></head>
<body>
<script>
function Konstructor (str) {
alert ("Kreated new Konstructor Obj w/ str : " + str);
}
</script>
<input type="button"
onclick="new Konstructor('button clicked')"
value="Click here to test local creation of stuff"
/>
<input type="button"
onclick="window.open ('./childWin.html', 'child');"
value="Click here to launch a window that'll try and create a Ktor object"
/>
</body>
</html>
==================================================
childWin.html:
<html>
<head><title>test scope (subwin)</title></head>
<body>
Hello there!
<script>
alert ("Function code is :" + window.opener.top.Konstructor);
new window.opener.top.Konstructor ("From child!");
</script>
</body>
</html>
[I've checked the archives, found some postings that were more or less
related to my problem, but couldn't find a satisfying answer.]
Let's say I have a webapp 'root' window into which I include all
my important JavaScript, including functions that I use as
constructors. Let's say I have a 'class' whose constructor is
'Konstructor'. (weird name, but it's only for the example)
If, from this root window, I create a new window
(window.open('./subwin.html')), I can access the code of the
constructor (with: window.opener[.top].Konstructor), but I cannot
execute a "new window.opener[.top].Konstructor (args)", because IE
complains about an invalid function call.
(IE has this problem, Mozilla runs the code fine. Other browsers
untested)
Has anyone any idea about this?
What prevents me from doing so?
Is it improper JS?
Any pointer/idea where to look?
Thanks much for any information you could provide
Best regards,
Arnaud
Follows: A test-case that works w/ Mozilla, and fails w/ IE:
==================================================
root.html:
<html>
<head><title>test scope</title></head>
<body>
<script>
function Konstructor (str) {
alert ("Kreated new Konstructor Obj w/ str : " + str);
}
</script>
<input type="button"
onclick="new Konstructor('button clicked')"
value="Click here to test local creation of stuff"
/>
<input type="button"
onclick="window.open ('./childWin.html', 'child');"
value="Click here to launch a window that'll try and create a Ktor object"
/>
</body>
</html>
==================================================
childWin.html:
<html>
<head><title>test scope (subwin)</title></head>
<body>
Hello there!
<script>
alert ("Function code is :" + window.opener.top.Konstructor);
new window.opener.top.Konstructor ("From child!");
</script>
</body>
</html>