Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 18th, 2007, 03:37 PM
Authorized User
 
Join Date: Nov 2006
Location: St James, Manitoba, Canada.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Set window position using button

Hi:
I am trying to open a window at a specific location on the screen and my code doesn't seem to be working, can someone please help?
Here is my code:

HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>
</TITLE>
<META NAME="Generator" CONTENT="TextPad 4.4">
<META NAME="Author" CONTENT="?">
<META NAME="Keywords" CONTENT="?">
<META NAME="Description" CONTENT="?">
<script type="text/javascript" src="Final Exam Question 7A and 7B.js"></script>
</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">

<BR>Part 7a
<BR>10 marks<BR>
<table align="center">
<form name="f1">

<tr><td>
<ol>
<li>Select a file[list]
<li>YOU WILL NEED TO CREATE THOSE FILES
<li>the file names on the buttons below indicate what the files initial background colours should be.
</ul>
<li>Select its location on the screen
<li>Press the open window button.[list]
<li>The file should open in a window that is 200 by 200 with no tools.
</ul>
<li>Once open the user can then
<UL>
  <LI>close the window using the same button they used to open it (the label
  should then say close window)
  <LI>change the background colour of that page.
  <li>While open the small window should ALWAYS stay on top of the big window
</UL>
</ol>
<br>
<center>
<BR>Part 7b
<br>5 marks
</center>[list]
  <LI>enter text in the input box and press a button to display it in a text box in the page being displayed in the new window and its status bar
  <li>the buttons should not be clickable until the new window is open.
  <LI>enter text in the input box of the page in the new window and press a button(on that page) to display text the window status bar of this big window
</ul>
</td></tr>
</table>
<BR>
<TABLE width="90%" border=1>
  <TBODY>
  <TR>
    <TH>file
    <TH>location
  <TR>
    <TD width="50%">
       <INPUT type=button name="colour_butt1" value="red.htm" onClick="file_name='red.htm'">
       <BR><INPUT type=button name="colour_butt2" value=blue.htm onClick="file_name='blue.htm'">
       <BR><INPUT type=button name="colour_butt3" value=green.htm onClick="file_name='green.htm'">
       <BR><INPUT type=button name="colour_butt4" value=yellow.htm onClick="file_name='yellow.htm'">
    </TD>
    <TD width="50%">
       <INPUT type="button" value="top left" onClick="win_loc='left=0,top=0'">
       <BR><INPUT type=button value="bottom left">
       <BR><INPUT type=button value="top right">
       <BR><INPUT type=button value="bottom right">
    </TD>
  </TR>
  <TR>
    <TD align=middle colSpan=2>
       <INPUT type=button value="open window" name=button1 onClick="win_open()">
    </TD>
  </TR>
  <TR>
    <TD width="50%">
      <CENTER>background colour</CENTER>
      <INPUT type=button value=gold>
      <BR><INPUT type=button value=purple>
      <BR><INPUT type=button value=orange>
      <BR><INPUT type=button value=white><BR>
    </TD>
    <TD width="50%">
       <INPUT type=input>
       <BR><INPUT type=button value="text in new windows' text box">
       <BR><INPUT type=button value="text in new windows' status bar">
       <BR><BR>also check if the field is not filled when a button is pushed
   </TD>
 </TR>
 </TBODY>

 </form>

 </TABLE>

</BODY>
</HTML>




Javascript

alert("Starting script")
var file_name,win_loc;
function win_open()
{

window.status=win_loc
alert("File name is " + file_name + "Position is " + win_loc)
window.open(file_name,"colourwin","width=200,heigh t=200,win_loc")
window.open(file_name,"colourwin2","width=200,heig ht=200,top=0,left=0")
}

Thanks


Reply With Quote
  #2 (permalink)  
Old January 18th, 2007, 03:45 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

On the window that your opening do something like this:

<script language="javascript">
self.moveTo(0,0);
</script>

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #3 (permalink)  
Old January 18th, 2007, 04:03 PM
Authorized User
 
Join Date: Nov 2006
Location: St James, Manitoba, Canada.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that works but not what the instructor wants. He wants us to open the window at that location, not move it after it is opened. The second window.open statement works fine so I'm baffled as to why the first one doesn't. It displays the string I pass it in the status bar correctly so why won't it position the window correctly?
Thanks anyway for your reply, I learned something new :).
Reply With Quote
  #4 (permalink)  
Old January 18th, 2007, 04:15 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The reason is, you have included win_loc as a string literal, not a variable.

Try this:

window.open(file_name,"colourwin","width=200,heigh t=200," + win_loc)

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #5 (permalink)  
Old January 18th, 2007, 04:37 PM
Authorized User
 
Join Date: Nov 2006
Location: St James, Manitoba, Canada.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much, that worked like a charm. I'll be sure not to miss something like that again.

Thanks again

Reply With Quote
  #6 (permalink)  
Old January 18th, 2007, 04:51 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Glad it worked out for you ^^

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Form DataSet Position to DataGrid Selection robzyc C# 2 September 9th, 2007 04:28 AM
how to open new window on button click nittin14 ASP.NET 1.0 and 1.1 Basics 8 April 28th, 2007 12:13 AM
How to set cursor position in a textbox? zayasv VB.NET 2 April 29th, 2006 07:09 AM
Dynamic generation of .Net button in a position sonaldewle General .NET 0 April 3rd, 2006 03:51 AM
set size of window on load SoC Javascript How-To 3 September 14th, 2004 03:22 AM



All times are GMT -4. The time now is 09:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.