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!

Body OnBlur causing problems

Status
Not open for further replies.

slickyboi

Programmer
Oct 16, 2003
29
0
0
US
Hello all,

I set an onblur function to my pop-up window so if anyone clicks away from it.. It will close. But in that popup window I have a link if a user wishes to go to this link he can.. But the pop-up just seems to want to close when the user clicks the link and it doesnt even launch the linked page. I wanted people to be able to close the window by click away from it if that is not what they want. But if it is there is a link in that pop-up window to install a driver for them. I wanted to know if anyone can tell me what Im missing here.. Thank you! :)

<html>
<head>
<title>CopyStation</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body onBlur=&quot;self.close()&quot;>
<p><strong><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><img src=&quot;new_copystationv2.gif&quot; width=&quot;329&quot; height=&quot;33&quot;></font></strong><br>
<strong><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>Copier Name:</font></strong><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
AW2A-3883-IR5020<br>
<strong>Copy Location:</strong> Copy Center <br>
</font><br>
<font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;> <a href=&quot; target=&quot;_blank&quot; OnClick=&quot;window.close()&quot;>
Click here</a></font></p>
<p><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;></a> </font><font size=&quot;1&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
</body>
</html>
 
navigating via a link is still considered blurring. you should wrap the close() call in a function that uses a condition, and have your link alter the condition so as not to fire the close() call. something like this perhaps:

function doClose() {
if (!self.cancelClose)
window.close();
}


<body onblur=&quot;doClose();&quot;>

<a href=&quot; onclick=&quot;self.cancelClose = true;&quot;>link</a>

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Thanks for your response...
I went ahead and added the javascript into the head

<script>
function doClose() {
if (!self.cancelClose)
window.close();
}
</script>

added onblur=&quot;doClose();&quot;> into the body tag
and added onclick=&quot;self.cancelClose = true;>my link to the a href... It still seems to close with out going to the link when you click on it..

<html>
<head>
<title>CopyFaxStation</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script>
function doClose() {
if (!self.cancelClose)
window.close();
}
</script>
</head>

<body onblur=&quot;doClose();&quot;>
<p><strong><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><img src=&quot;new_copyfaxstationv2.gif&quot; width=&quot;329&quot; height=&quot;33&quot;></font></strong><br>
<strong><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>Copier Name:</font></strong><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
AW2A-3883-IR5020<br>
<strong>Copier Location:</strong> Copy Center Room 3883<br>
</font><br>
<font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>This Copier has
printing capabilities, if you wish<br>
to print from this multi-functional copier and would<br>
like to install.. <a href=&quot; target=&quot;_blank&quot; onclick=&quot;self.cancelClose = true;&quot;>
Click here</a></font></p>
<p><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;></a> </font><font size=&quot;1&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>For
any questions please contact the Seattle HelpDesk<br>
at Ext. 54357.</font></p>
</body>
</html>
 
interesting...seems that in IE body.onblur happens before the link.onclick.

works for me in IE and Moz if you change
onclick=&quot;self.cancelClose = true;&quot;

to
onmousedown=&quot;self.cancelClose = true;&quot;





=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Whoo hoo!

You rock jemminger! That worked!

I just had to add onClick=&quot;self.close()&quot; too so it will close itself after in jumps to the link.. Thanks man! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top