View Full Version : window.open function

03-22-2005, 07:14 AM
Hi, ive been studing javascript for a little bit, and ive been giving 9 exercise that involve createing a new window, each one of these has the same problem beacause there basically the same just adding more stuff as we go along.

my code is exactly like my handouts so it has to be somthing simple that the teacher forgot or is being sneaky, i dont want any drastic changes please.


function MakeA Win(){
win.document.write("<body><h3 align=center>WindowOne</h3>");

--------------------------form button------------------------

<form action="">
<input type="submit" name="mywin" value="Create Window!"
onclick="MakeA Win()" />


this is just bugging me!

03-22-2005, 08:16 AM
What's your question? You didn't mention the problem you're talking about.

But judging from the script you posted, I can guess that the problem seems to be in the function name. Space is not allowed in function names. Is that a typo?

03-22-2005, 08:36 AM
it doesn't open a new window, try it yourself. And i dont think it's the space in the function name.

03-22-2005, 08:50 AM
Aside from the function name, you haven't got a comma between
directories=yes and status=yes...

03-22-2005, 09:39 AM
And the button must be a regular button and not a submit button.

<input type="button" ...>

and document should be closed after the last document.write.


The popup window may also be blocked by popup blocker installed in your system (if any)

03-22-2005, 10:11 AM
i tried all the suggestions and it still doesn't work. Could somebody try the javascript on their browser?

Im just wondering why my lecturer would make me do it this way.

03-22-2005, 10:57 AM
Can you post the whole and final code of the page that you're working with? Also what browser are you using?

03-22-2005, 11:03 AM
sure, here it is. Im using firefox, but ive used opera, and IE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>New Window</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="standard.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">
function MakeA Win(){
win.document.write("<html><head><title>Window 2</title></head>");
win.document.write("<body><h3 align=center>Window One</h3>");

<form action="#">
<input type="submit" name="mywin" value="Create Window!"
onclick="MakeA Win()" />

03-22-2005, 11:25 AM
Did you really follow all the suggestions? :rolleyes:

If you remove the space in the function name and the newline between "directories=yes" and ",status=yes", it will work.

To debug, open the Tools->Javascript Console to see javascript errors. That will tell you the exact error and will help you fix it.

03-22-2005, 11:33 AM
It works's that's great!

I must have given you the original version.

Because i tried it with the changes and it still didn't work. It must be my browser or somthing.

thanks for the help, it's appreciated

03-22-2005, 11:39 AM
Or it must be the user, j/k :D

In the future, use the Javascript console to fix errors.