...

View Full Version : Want to change focus to child window.



elcaro2k
06-16-2004, 05:42 PM
I am submitting this form:

<form method=post name=whform target=blank action=https://ut.secure.bluecrossca.com/wh/landing.do>

With this link:

<a href="#" onclick=openWH()>Whole Health Link</a>

that calls this function:

function openWH(){
document.whform.submit();
}

What I want to do is if the window that this opens has already been opened by the user, then I just want the link to togle back to the child window. I tried self.blur and that does nothing.

Any help is greatly appreciated!!!

elcaro2k
06-16-2004, 09:03 PM
I have tried:

window.blur()
this.blur()
self.blur()

none work. The window that I am working is a child frame, would this matter?

glenngv
06-17-2004, 04:33 AM
var win;
function openWH(){
var f = document.whform;
if (!win || win.closed){
win = window.open('about:blank', f.target);
}
win.focus();
f.submit();
}

But if you will make your submit link as input type=submit or type=image, the code will be simpler and will work even if javascript is disabled.


var win;
function createTargetWin(f){
f (!win || win.closed){
win = window.open('about:blank', f.target);
}
win.focus();
}
<form ... target="blank" onsubmit="createTargetWin(this)">
...
<input type="submit" value="Submit" />
or
<input type="image" src="submit.jpg" />
</form>

I can't use it in the original code because calling formRef.submit() will unexplicably not trigger the form onsubmit event handler.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum