close window using HTML?

liunx

Guest
I have learned to design web pages with dreamweaver...i know, i know. So of course I relate HTML with a Tandy 386.<br />
But know it seems I have gotten too far without knowing any HTML. I added a behavior to my web page in Dreamweaver the opens another url in another window, but I don't have a behavior that closes the original window. Can I do this with HTML? I know I can view code in DW, but I don't know what to add to that code to make the window close. Thanks for any help you can give.<!--content-->Sounds like you are getting way out of your depth. What Dreamweaver calls 'Behaviours' are actually JavaScripts. To simply open a URL in another window you don't need to use a Behaviour, you just need to use:<br />
<br />
<a href=http://www.htmlforums.com/archive/index.php/"http://www.url.com" target="_blank"><br />
<br />
But to then have the original window close you need to use JavaScript. I don't know enough myself to tell you how. I don't quite understand why you want to do this anyway, surely it would be easier to just open the link in the same window if you are only going to close the original one anyway, but maybe you have your reasons.<br />
<br />
My advice is that this would be a good time to start learning HTML, it is really very easy and straightforward once you know how. Then maybe you can get into JavaScript after that. There are many sites that offer cut and paste JavaScripts but more often than not you still need some knowledge of the language to implement them properly.<br />
<br />
Here are a couple:<br />
<br />
<!-- w --><a class="postlink" href="http://www.a1javascripts.com">www.a1javascripts.com</a><!-- w --><br />
<!-- w --><a class="postlink" href="http://www.javascript.internet.com">www.javascript.internet.com</a><!-- w --><!--content-->Well, as Goldi mentioned.... you use JavaScript to close your window. BUT if you did not open the window with JavaScript, you can't just close it. <br />
<br />
Example: If the user types in your URL, clicks on a link to open in a new window.... You can't close the main window. Why? You didn't open it.... the surfer did. <br />
<br />
I'd give you the code to close the main window, but as I stated it won't close it anyway. Also, if your dependant on DW you won't know what to do with the code anyway. <br />
<br />
I'd suggest that you take a cursory trip down HTML/ JavaScript lane. It will help to show you what you can do. And although DW is a good program..... its a far cry from knowing web dev. <br />
<br />
Good luck!<!--content-->Javascript is very useful if you're taking web development seriously. Some tutorials to get you started:<br />
<!-- m --><a class="postlink" href="http://www.a1javascripts.com/tutorials/">http://www.a1javascripts.com/tutorials/</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.htmlgoodies.com/beyond/js.html">http://www.htmlgoodies.com/beyond/js.html</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.webreference.com/js/">http://www.webreference.com/js/</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://javascript.com/">http://javascript.com/</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.4guysfromrolla.com/webtech/111599-1.shtml">http://www.4guysfromrolla.com/webtech/111599-1.shtml</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.wdvl.com/Authoring/JavaScript/Tutorial/">http://www.wdvl.com/Authoring/JavaScript/Tutorial/</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.echoecho.com/javascript.htm">http://www.echoecho.com/javascript.htm</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.javascriptgate.com/">http://www.javascriptgate.com/</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.1001tutorials.com/javascript/index.shtml">http://www.1001tutorials.com/javascript/index.shtml</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.findtutorials.com/DirSearch.asp?ST=0&Query=javascript&CatID=&x=3&y=5">http://www.findtutorials.com/DirSearch. ... D=&x=3&y=5</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.htmlcenter.com/">http://www.htmlcenter.com/</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.jsworld.com/">http://www.jsworld.com/</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://tech.irt.org/articles/script.htm">http://tech.irt.org/articles/script.htm</a><!-- m --><!--content-->You will have to code both the open and the close because in order to <br />
close it you have to be able to reference a variable created by the <br />
open. <br />
<br />
<script language="JavaScript"><br />
<!-- <br />
function openWindow()<br />
{<br />
var x=window.open(url,name,chrome)<br />
}<br />
function closeWindow()<br />
{<br />
x.close();<br />
}<br />
//--><br />
</script><br />
<br />
In the open: url is the name of the page, name is the title to<br />
go on the window and chrome are the window control items.<br />
<br />
To learn how to set those up:<br />
<br />
you need to spend some time at:<br />
<br />
<!-- m --><a class="postlink" href="http://developer.netscape.com/docs/manuals/communicator/jsref/index.htm">http://developer.netscape.com/docs/manu ... /index.htm</a><!-- m --><br />
<br />
If you want to do thing with scripting, you need to read the the manual,<br />
because right now it sounds like you ar in over your head.<br />
<br />
Cd&<!--content-->
 
Back
Top