?
Solved

How do I open a New  Window using JavaScript

Posted on 1999-11-29
5
Medium Priority
?
216 Views
Last Modified: 2013-12-16
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.
0
Comment
Question by:soxo
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

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

Gniss
0
 

Author Comment

by:soxo
ID: 2242899
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
 

Author Comment

by:soxo
ID: 2242915
The error I get is:
Error reading Script
line: 10
Char: 1
Error:  object expected
Code: 0
0
 
LVL 1

Expert Comment

by:Gnissman
ID: 2242919
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
 
LVL 2

Accepted Solution

by:
kamalranjan earned 100 total points
ID: 2243317
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

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question