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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window focus

Status
Not open for further replies.

lakeside12

Programmer
Apr 20, 2009
43
CA
Can you help with my process flow please.

I was successfully using some javascript error handling to force the user to go back to the page 1 with errors and correct them. It worked a treat!
Code:
<html>
<script type="text/javascript">
{
	alert("<% Response.write "Please correct your: " &emsg  %>")
	history.back();
}
</script>
</html>

The above code is on Page2 and handles the errors. I recently introduced in the hyperlink on Page 1 a Target=_blank as opposed to _Self as I wanted to create separate windows.

Now of course the error handling will not work as there is no history to go back to

How can I selectively force a user to go to Page 1 when there is an error detedcted.

Many thanks
 
Short answer: You can't.

Long answer: Depending on how you opened the new window you could target its parent and focus it, however the window.focus doesn't work well across browsers for different reasons. Firefox for instance can block any attempt to manipulate its windows so the focus() call does not work.

You're best bet would be to alert, and then close the window. In most cases this will return the user to the original page.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top