How do I open a New Window using JavaScript

I am using CoffeeCup to do a simple Wep page to launch a new window upon clicking a button.  I got a script error message upon clicking on my button.  I'm using JavaScript.
soxoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GnissmanCommented:
Could you post your JavaScript code so that we can check it for errors? Which error do you get?

Gniss
0
soxoAuthor Commented:
This is how the open window looks.  The new window is loaded below this

<HTML>
<!-- Created with the CoffeeCup HTML Editor++ -->
<!--          http://www.coffeecup.com        -->
<!--  Brewed on November 29 1999 7:31:53 PM   -->
<HEAD>
  <TITLE>Assignment 3</TITLE>
  <META name="description" content="">
  <META name="keywords" content=""><P><SCRIPT LANGUAGE= "JavaScript"><!--><P>function openWin(URL){openedwindow=window.open(URL,"thewindow","width=400,height=550");}//--><P></SCRIPT></HEAD><P><BODY><A HREF= "javascript:openWin('openedwindow.html');"></A>
</HEAD>
<BODY><P>BGCOLOR="FABEF3" TEXT="2E3C9E" LINK="0000FF" VLINK="800080"><P>Author is Sheryl Oxendine. The date of last modifications are 29 Nov 99.  This JavaScript will open a new window called opened window.<P><FORM><INPUT TYPE = "BUTTON" VALUE = "Click Please" onClick = "openWin();"></FORM>


</BODY>
</HTML>

The name of the new window is NewWin.html
0
soxoAuthor Commented:
The error I get is:
Error reading Script
line: 10
Char: 1
Error:  object expected
Code: 0
0
GnissmanCommented:
Your HTML-code was somewhat corrupted. Try this cleaned up version instead:

<HTML>
<!-- Created with the CoffeeCup HTML Editor++ -->
<!--          http://www.coffeecup.com        -->
<!--  Brewed on November 29 1999 7:31:53 PM   -->
<HEAD>
  <TITLE>Assignment 3</TITLE>
  <META name="description" content="">
  <META name="keywords" content="">
  <SCRIPT LANGUAGE= "JavaScript"><!-->
      function openWin(URL){
        openedwindow=window.open(URL,"thewindow","width=400,height=550");
      }//-->
  </SCRIPT>
</HEAD>
<BODY BGCOLOR="FABEF3" TEXT="2E3C9E" LINK="0000FF" VLINK="800080">
  <A HREF= "javascript:openWin('openedwindow.html');"></A>

<P>Author is Sheryl Oxendine. The date of last
modifications are 29 Nov 99.  This JavaScript will open a new window called opened window.<P><FORM><INPUT TYPE = "BUTTON"
VALUE = "Click Please" onClick = "openWin();"></FORM>


</BODY>
</HTML>



Gniss
0
kamalranjanCommented:
hi,

Even the code given by gniss doesn't work. The problem is you are using the link filename as parameter to the function openWin but not passing any parameter while giving a call to the function. Try the following rectified code to open the page newwin.html

<HTML>
<!-- Created with the CoffeeCup HTML Editor++ -->
<!--          http://www.coffeecup.com        -->
<!--  Brewed on November 29 1999 7:31:53 PM   -->
<HEAD>
  <TITLE>Assignment 3</TITLE>
  <META name="description" content="">
  <META name="keywords" content="">
  <SCRIPT LANGUAGE= "JavaScript"><!-->
function openWin(URL){
  openedwindow=window.open(URL,"thewindow","width=400,height=550");
}//-->
  </SCRIPT>
</HEAD>
<BODY BGCOLOR="FABEF3" TEXT="2E3C9E" LINK="0000FF" VLINK="800080">
  <A HREF= "javascript:openWin('openedwindow.html');"></A>

<P>Author is Sheryl Oxendine. The date of last
modifications are 29 Nov 99.  This JavaScript will open a new window called opened window.<P><FORM><INPUT TYPE = "BUTTON"
VALUE = "Click Please" onClick = "openWin('newwin.html');"></FORM>

</BODY>
</HTML>


Hope this will solve your problem

Kamal Ranjan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.