Enjoy an ad free experience by logging in. Not a member yet?
Register .
03-22-2005, 06:14 AM
PM User |
#1
New to the CF scene
Join Date: Jun 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
window.open function
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----------------------------------
function MakeA Win(){
win=window.open("","results","toolbar=yes,width=200,height=200,directories=yes
,status=yes,scrollbars=yes,resize=yes,menubar=yes");
win.document.write("<html><head><title>Window2</title></head>");
win.document.write("<body><h3 align=center>WindowOne</h3>");
win.document.write("</body></html>");}
--------------------------form button------------------------
<form action="">
<input type="submit" name="mywin" value="Create Window!"
onclick="MakeA Win()" />
</form>
----------------------------------------------------------------
this is just bugging me!
Last edited by sunzini; 03-22-2005 at 09:13 AM ..
03-22-2005, 07:16 AM
PM User |
#2
Supreme Master coder!
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
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, 07:36 AM
PM User |
#3
New to the CF scene
Join Date: Jun 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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, 07:50 AM
PM User |
#4
Regular Coder
Join Date: Dec 2003
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Aside from the function name, you haven't got a comma between
directories=yes and status=yes...
__________________
UNDER CONSTRUCTION
03-22-2005, 08:39 AM
PM User |
#5
Supreme Master coder!
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
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.
win.document.close();
The popup window may also be blocked by popup blocker installed in your system (if any)
03-22-2005, 09:11 AM
PM User |
#6
New to the CF scene
Join Date: Jun 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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, 09:57 AM
PM User |
#7
Supreme Master coder!
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
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, 10:03 AM
PM User |
#8
New to the CF scene
Join Date: Jun 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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">
<head>
<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=window.open("","results","toolbar=yes,width=200,height=200,directories=yes
,status=yes,scrollbars=yes,resize=yes,menubar=yes");
win.document.write("<html><head><title>Window 2</title></head>");
win.document.write("<body><h3 align=center>Window One</h3>");
win.document.write("</body></html>");}
//-->
</script>
</head>
<body>
<form action="#">
<input type="submit" name="mywin" value="Create Window!"
onclick="MakeA Win()" />
</form>
</body>
</html>
03-22-2005, 10:25 AM
PM User |
#9
Supreme Master coder!
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
Did you really follow all the suggestions?
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, 10:33 AM
PM User |
#10
New to the CF scene
Join Date: Jun 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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, 10:39 AM
PM User |
#11
Supreme Master coder!
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
Or it must be the user, j/k
In the future, use the Javascript console to fix errors.
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 02:40 AM .
Advertisement
Log in to turn off these ads.