Hi,

I am wondering if the following is possible.

I have written some javascript to create a pop up window from a link.
The popup window is intended to redirect to a web service so that it goes to a completely different 3rd party domain. The problem is that I must keep the session alive in the popup's parent window while the popup has focus.

This works if the popup is not redirected to an external server, but when it IS redirected as I need it to do, I always get the following error in firebug:

Code:
uncaught exception: Permission denied to set property Window.onblur
Line 0
If I redirect back to my local server, the script starts working again and the parent window can detect whether the popup has focus.

I cant insert javascript code into the page I must redirect to since it belongs to a 3rd party.

But before you waste your time looking at the code - it may be that it is not even possible to get the window properties/events of the popup window if it is redirected to a completely different server.

Am I correct in assuming this? If so, is there another suggested way to accomplish this (ie. keeping session alive when popup is redirected) ?

Here is my code:

Code:

<html>
	<head>
		<title>Js test</title>
		
		<script TYPE="TEXT/JAVASCRIPT">
			var newWindowObject = null;
			var newWindowFocus = false;
			var thisWindowFocus = true;
			var imgName = "keepAliveIMG";
			
			window.setInterval("checkFocus()", 10000);
			
			function openWindow(){
				
				if(newWindowObject == null || newWindowObject.closed)
				{				
					newWindowObject=window.open('popup.html','RedirectPlaneBizWindow');	
				}else{
					newWindowObject.focus();				
				}
				
			}
			

			function checkFocus(){

			
				if (navigator.appName == "Microsoft Internet Explorer") {
			
					var genDoc = newWindowObject.document;
			
					self.onfocus = function(){
						// focus is on current window, so this counds as the current application having focus
						thisWindowFocus = true;
						
					}
					
					self.onblur = function(){
						thisWindowFocus = false;
					}
					
					genDoc.onfocusout = function(){
						//alert("out of focus");
						var testSpan = returnObjById("testSpan2");
						testSpan.innerHTML ="FF out of focus";
						newWindowFocus = false;
					}						

					genDoc.onfocus = function(){
						//window.setInterval("keepMeAlive('keepAliveIMG')", 10000);							
						newWindowFocus = true;
					}
				
				}else{
						
					self.onfocus = function(){
						// focus is on current window, so this counds as the current application having focus
						thisWindowFocus = true;
						
					}
					
					self.onblur = function(){
						thisWindowFocus = false;
					}
					
					newWindowObject.onblur = function(){
						//alert("out of focus");
						var testSpan = returnObjById("testSpan2");
						testSpan.innerHTML ="FF out of focus";
						newWindowFocus = false;
					}						

					newWindowObject.onfocus = function(){
						//window.setInterval("keepMeAlive('keepAliveIMG')", 10000);							
						newWindowFocus = true;
					}

	
				}					
						
					if(newWindowFocus == true || thisWindowFocus == true){
					
						keepMeAlive();
					
						var testSpan = returnObjById("testSpan2");
						testSpan.innerHTML ="FF in focus";
						

					}else{
					
						var testSpan = returnObjById("testSpan2");
						testSpan.innerHTML ="FF out of focus2";
					}
			
			}
			
		
			function keepMeAlive() {
				myImg = returnObjById(imgName);
				
				if (myImg) myImg.src = myImg.src.replace(/\?.*$/, '?' + Math.random());
				var testSpan = returnObjById("testSpan");
				testSpan.innerHTML = myImg.src;
			}
			

			function returnObjById( id )
            {
                if (document.getElementById)
                    var returnVar = document.getElementById(id);
                else if (document.all)
                    var returnVar = document.all[id];
                else if (document.layers)
                    var returnVar = document.layers[id];
                return returnVar;
            }
			
		</script>
	</head>
	
<body>
<img id="keepAliveIMG" width="1" height="1" src="SessionStateImage.gif?" />
<a href="#" onclick="openWindow();return false;">test</a>

<span id="testSpan"></span><br />
<span id="testSpan2"></span>

</body>
</html>