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

Can someone look at my code please

Status
Not open for further replies.

beckym

Technical User
Nov 9, 2000
38
CA
I am new at javascript. I am trying to close a sub window with text and not a button and it is not working. Could someone tell me what I am missing. Thanks

<HTML>
<HEAD>
<TITLE>Static Media</TITLE>
<SCRIPT language=&quot;Javascript&quot;>
<!--
function doNavigation () {

window.close(); }
// -->
</SCRIPT>


</HEAD>
<BODY bgcolor=&quot;#453667&quot; marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>

<table border =&quot;0&quot;>

<td ><img src=&quot;img/lg_express_1.jpg&quot; width=&quot;697&quot; height=&quot;50&quot; border=&quot;0&quot;></td>
</tr>

<td width=&quot;100%&quot; valign=&quot;middle&quot; align=&quot;right&quot; bgcolor=&quot;#604B6B&quot; height=&quot;25&quot;><font face=&quot;verdana, arial&quot; size=&quot;1&quot; font color=&quot;#EFEEE3&quot;>

    <a href=&quot;mailto:rmccormack11@shaw.ca&quot;><font color=&quot;#EFEEE3&quot; size=1>Contact</font></a>
  |  <a href=&quot;resume.pdf&quot;><font color=&quot;#EFEEE3&quot; size=1>Resume</font></a>
  |  <a href=javascript:window.close()><font color=&quot;#EFEEE3&quot; size=1>Close</font></a>    
</font>



</table>


</BODY>
</HTML>
 
I put that page in my browser and it worked fine. However, I would make it a practice to put the link inside double quotes AND issue self.close(); instead of window.close();. It's sort of a guarantee that the active window will be the one that's closed.

Code:
<a href=&quot;javascript:self.close();&quot;><font color=&quot;#EFEEE3&quot; size=1>Close</font></a>

What problems are you having and why do you have the JavaScript function in your script tags. Is that just part of your testing ??

ToddWW
 
thanks for the response. I tryed the code you gave me and still nothing happens, it is a dead link. Is the fuction in the script tag unneeded? What should go in the script tags. Beckym
 
Becky, for now, if all you want to do is execute that one command to close the window, you don't need that function in between your script tags. The method javascript: in your href tells the browser that a JavaScript method is following.

Let's troubleshoot. Just load this into your browser and tell me if it's still a dead link. I removed the text formatting so you could see the link.
Code:
<html>
<head>
</head>
<body>
<a href=&quot;javascript:self.close()&quot;>Close</a>
</body>
</html>

If that works, then build around it and let me know what happens.

ToddWW
 
the code you gave me worked . but when I incorporated it into my code it is still a dead link. Here's your code with mine

<HTML>
<HEAD>
<TITLE>Static Media</TITLE>


</HEAD>
<BODY bgcolor=&quot;#43385F&quot; marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>

<table border =&quot;0&quot;>

<td ><img src=&quot;img/banner.gif&quot; width=&quot;697&quot; height=&quot;41&quot; border=&quot;0&quot;></td>
</tr>
<tr bgcolor=&quot;#604B6B&quot;>
<td width=&quot;100%&quot; valign=&quot;middle&quot; align=&quot;right&quot; bgcolor=&quot;#604B6B&quot; height=&quot;20&quot;><font face=&quot;verdana, arial&quot; size=&quot;1&quot; font color=&quot;#EFEEE3&quot;>

    <a href=&quot;mailto:rmccormack11@shaw.ca&quot;><font color=&quot;#EFEEE3&quot; size=1>Contact</font></a>
  |  <a href=&quot;resume.pdf&quot;><font color=&quot;#EFEEE3&quot; size=1>Resume</font></a>
  |  <a href=&quot;javascript:self.close()&quot;>Close</a>

</td>
</tr>


</table>


</BODY>
</HTML>

thanks, Beckym
 
OK, that works great here in IE 5 and NS 6. The html needs a little clean up. I wish I could duplicate your problem here. Here's what I would like you to do..

Start back with that one small page that worked. And build your page around it, piece by piece testing as you go along. Something's not right there, but I really don't see it.

ToddWW
 
Ok, I rebuilt the code from the what you gave me. It does work when it is loaded into a regular window. However I am loading it in a subwindow with frames. The code I have been giving you is a top frame of a subwindow.

Here is the code that works now in a regular window. Thanks again for all your help


<HTML>
<HEAD>
<TITLE>Dynamic Media</TITLE>

</HEAD>
<BODY bgcolor=&quot;#43385F&quot; marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>
<table border =&quot;0&quot;>
<tr>
<td ><img src=&quot;img/banner_dyn.gif&quot; width=&quot;597&quot; height=&quot;41&quot; border=&quot;0&quot;></td>
</tr>
<tr bgcolor=&quot;#604B6B&quot;>
<td width=&quot;100%&quot; valign=&quot;middle&quot; align=&quot;right&quot; bgcolor=&quot;#604B6B&quot; height=&quot;20&quot;><font face=&quot;verdana, arial&quot; size=&quot;1&quot; font color=&quot;#EFEEE3&quot;>

    <a href=&quot;mailto:rmccormack11@shaw.ca&quot;><font color=&quot;#EFEEE3&quot; size=1>Contact</font></a>
  |  <a href=&quot;resume.pdf&quot;><font color=&quot;#EFEEE3&quot; size=1>Resume</font></a>
  | <a href=&quot;javascript:self.close()&quot;><font color=&quot;#EFEEE3&quot; size=1>Close</font></a>    
</td>
</tr>


</table>

</body>
</html>

thanks Beckym
 
Oh, that's a whole different ball game..

Try these options, and not necessarily in this order.
Code:
href=&quot;javascript:parent.close();&quot;
href=&quot;javascript:top.close();&quot;
href=&quot;javascript:self.parent.close();&quot;
href=&quot;javascript:self.top.close();&quot;

ToddWW
 
Yes that was the problem and the right code. Thanks alot for your help, Beckym
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top