Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

!win.closed not working with IE6

Status
Not open for further replies.

danielvaughan

Technical User
Joined
May 28, 2006
Messages
3
Location
AU
Hi Guys,

I seem to be having a problem with !win.closed and Internet Explorer 6. My script works perfectly well in firefox. I've included window.alerts to confirm this. IE just does not recognise !win.closed and therefore, wont enter that part of the script.

By the way, the script is fed some basic window address and size data from Macromedia Flash.

Any help would be greatly appreciated.

This is the script i'm working with:

function shopcart(mypage,myname,w,h,features) {
if (!window.win) {
window.alert('loading for the first time');
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{
winl = 0;wint =0;
}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
return ">> Hi Flash.";
}else {
if (!win.closed) {
window.alert('switching to already open window');
win.window.focus();
}else {
window.alert('window already opened, but now closed - opening again');
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{
winl = 0;wint =0;
}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
return ">> Hi Flash.";
}
}
}
 
Hi Dan,

I've now included:
var win = "";
on the line before the function is defined. This should have defined win as global should it not?

However, the problem still occurs.

Regards
Daniel
 
Dan,

To clarify, this is my whole embeded script:

<script>
var win = "";
function shopcart(mypage,myname,w,h,features) {
if (!window.win) {
window.alert('loading for the first time');
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{
winl = 0;wint =0;
}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
return ">> Hi Flash.";
}else {
if (!win.closed) {
window.alert('switching to already open window');
win.window.focus();
}else {
window.alert('window already opened, but now closed - opening again');
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{
winl = 0;wint =0;
}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
return ">> Hi Flash.";
}
}
}

</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top