window focus error

I have the following code:
WinID = window.open(WinURL,WinTarget,'top=130,left=200,height=' + WinHeight + ',width=' + WinWidth + ',resizable=' + isresize + ',scrollbars=yes,menubar=' + ismenubar + ',toolbar=' + istoolbar + ',directories=no,location=' + islocation + ',status=' + isstatus);  
//WinID.focus();

The problem is that if I press the same link to open the window twice in a row it will not focus the window the second time, once it already has that page loaded in it. When I uncomment the focus line I get the error "Class doesn't support Automation"

any clues to the problem here, or how to get the window to focus everytime, even if you're just loading the same page into it again....
     
Chris_GrangerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris_GrangerAuthor Commented:
PS The funtion is being called from within a frame page, if that makes any difference....
0
fritz_the_blankCommented:
Here is the code that I use:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
function newWindow(strWin,strURL,intX,intY,intWidth,intHeight){
      strWin =window.open(strURL,strWin,'left=' + intX + ', screenX =' + intX + ', top=' + intY + ', screenY=' + intY + ', width=' + intWidth + ', height=' + intHeight + ', scrollbars=yes, toolbar=yes');
      strWin.focus();
}

//-->
</SCRIPT>

</HEAD>
<BODY>
<form>
<a href=# onClick="newWindow('wndFairCon','http://www.FairfieldConsulting.com',200,0,700,600);return false;">The guy who wrote this</a>
<form>
</BODY>
</HTML>
0
fritz_the_blankCommented:
Now what you will want to do is to check to see if the window already exists:

if(strWin){
   strWin.focus();
}

FtB
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

James RodgersWeb Applications DeveloperCommented:
>>Now what you will want to do is to check to see if the window already exists:
 you will also need to ensure that the window has not closed, if (strWin) will check that the window was opened and then allow you to set focus but strWin will also detemine true even if strWin was set and the window has been closed

if(strWin && !strWin.closed){
   strWin.focus();
}
0
Chris_GrangerAuthor Commented:
I've tried these and I still get this error. There must be something obvious worng with my code for it to keep coming up with this error: class does not support automation. If I leave the focus out it works fine but of course, doesn't focus the window... Here's the code:

function NewWindow1(WinURL,WinTarget,WinWidth,WinHeight,isresize,ismenubar,istoolbar,islocation,isstatus){      
var WinID = window.open(WinURL,WinTarget,'top=130,left=200,height=' + WinHeight + ',width=' + WinWidth + ',resizable=' + isresize + ',scrollbars=yes,menubar=' + ismenubar + ',toolbar=' + istoolbar + ',directories=no,location=' + islocation + ',status=' + isstatus);  
WinID.focus();
}


<a  class="navs"  HREF="JavaScript:NewWindow1('termsmain.asp?spage=1#sec','terms','650','460','no','no','no','no','no')">secure payment service.</a>

cheers!
0
fritz_the_blankCommented:
<a  class="navs"  HREF="javascript:NewWindow1('termsmain.asp?spage=1#sec','terms','650','460','no','no','no','no','no');return false;">secure payment service.</a>


Fritz the Blank
0
fritz_the_blankCommented:
Sorry, forget that.

This seems to work...

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
function NewWindow1(WinURL,WinTarget,WinWidth,WinHeight,isresize,ismenubar,istoolbar,islocation,isstatus){    
      var WinID = window.open(WinURL,WinTarget,'top=130,left=200,height=' + WinHeight + ',width=' + WinWidth + ',resizable=' + isresize + ',scrollbars=yes,menubar=' + ismenubar + ',toolbar=' + istoolbar + ',directories=no,location=' + islocation + ',status=' + isstatus);  
      WinID.focus();
}

//-->
</SCRIPT>


</HEAD>
<BODY>

<a HREF="javascript:NewWindow1('termsmain.asp?spage=1#sec','terms','650','460','no','no','no','no','no');" class="navs"  >secure payment service.</a>


</BODY>
</HTML>


FtB
0
Chris_GrangerAuthor Commented:
Still getting a "class doesn't support automation" error when it pops up - linking to the "focus" line. Without that again, no error but no focus.
0
fritz_the_blankCommented:
The problem may be in the pop up itself? When I run the code here, I get the popup with focus, but of course the pop up is empty since I don't have access to your page...

FtB
0
Chris_GrangerAuthor Commented:
I still get it with just the above code when the popup isn't there (blank page), maybe it's a sensitive script alert setting I have IE set on?
0
fritz_the_blankCommented:
May I see your link as you are using it now?

FtB
0
Chris_GrangerAuthor Commented:
here it is, I've cut everything I can out of it and I still get the error when the popup opens - whether I use my popup page or another, something freaky is going on (I even restarted my machine...):

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
function NewWindow1(WinURL,WinTarget,WinWidth,WinHeight,isresize,ismenubar,istoolbar,islocation,isstatus){    
     WinID = window.open(WinURL,WinTarget);  
     WinID.focus();
}

//-->
</SCRIPT>


</HEAD>
<BODY>

<a HREF="javascript:NewWindow1('termsmain.asp?spage=1#sec','terms','650','460','no','no','no','no','no');">secure payment service.</a>


</BODY>
</HTML>
0
fritz_the_blankCommented:
I just changed the URL, and it works fine here:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
function NewWindow1(WinURL,WinTarget,WinWidth,WinHeight,isresize,ismenubar,istoolbar,islocation,isstatus){    
     WinID = window.open(WinURL,WinTarget);  
     WinID.focus();
}

//-->
</SCRIPT>


</HEAD>
<BODY>

<a HREF="javascript:NewWindow1('http://www.fairfieldConsulting.com','terms','650','460','no','no','no','no','no');">secure payment service.</a>


</BODY>
</HTML>



FtB
0
Chris_GrangerAuthor Commented:
It only occurs in my testing environment I have discovered...  Something in iis I wonder?
0
fritz_the_blankCommented:
If you like, I could post this page on my site so that you can test.

FtB
0
Chris_GrangerAuthor Commented:
cool, that would help eliminate some issues...

Cheers
0
fritz_the_blankCommented:
Here you go:

www.FairfieldConsulting.com/Chris.htm

It seems to be ignoring the size attributes but it works.

FtB
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris_GrangerAuthor Commented:
I get no error at the moment but it doesn't bring the already open window to the fore-front when the link is clicked again.

I think my error problem is caused by a dodgy IE...

Cheers
0
fritz_the_blankCommented:
Try adding this to your pop up:

window.onBlur=focus();

FtB
0
Chris_GrangerAuthor Commented:
that would force it toi the front all the time wouldn't it? I just want it to come to forefront when the link is clicked...
0
fritz_the_blankCommented:
Nevermind, then.

FtB
0
DanielsRJECommented:
I recently ran into the same problem: I'm using a "windowtricks.js" with a few standard routines for a long time now, and all of a sudden I was receiving these "Class doesn't support automation" errors on window.focus() lines. Only in IE, FireFox doesn't seem to care much.
I think it has something to do with one of the many hotfixes that have come out of the MS Headquarters (I had not updated my comp for a while, I'm behind a thorough fire wall etc).

In the end solved it by leaving the focus command out of the page that is opening the window, instead adding it to the new page being loaded into the new window, adding onLoad="javascript:window.focus()" tp the body tag. This shuts up IE very nicely ;-)

Richard
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.