Current location: Hot Scripts Forums » General Web Coding » JavaScript » Set browser window size


Set browser window size

Reply
  #1 (permalink)  
Old 06-15-06, 08:55 PM
Andy128 Andy128 is offline
Wannabe Coder
 
Join Date: Jun 2006
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Set browser window size

Not quite sure if this is the place to post this- but here it goes.

I am creating an error page in html that will also contain a php script.
Part of the script is to post the error message using echo().
The problem is that I want to have that error message not open up in a huge web page when it only contains a few lines of instruction. So do I set this parameter in the html code (body size etc..) or is this better set php or some other way. I would like to have it open in a window say- 300Width X 300Length. I am very new to this code stuff but am having a great time learning it. Here is my code if needed.

Quote:
if(strlen($name) == 0) {echo ("Please enter a name in the field provided- Thank you.");exit;}
I hope this is enough info. Thanks again. I am really enjoying this forum.

Andy
Reply With Quote
  #2 (permalink)  
Old 06-16-06, 04:29 AM
bd_coder bd_coder is offline
Newbie Coder
 
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
You can use JavaScript
Code:
<script language="javascript">
window.resizeTo(300,300);
</script>
__________________
------------------------------------
bd_coder
Reply With Quote
  #3 (permalink)  
Old 06-16-06, 07:30 AM
Andy128 Andy128 is offline
Wannabe Coder
 
Join Date: Jun 2006
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Where would I place this in realtion to the web page? Before body?
Before echo?

Thanks

Andy
Reply With Quote
  #4 (permalink)  
Old 06-16-06, 08:34 AM
bd_coder bd_coder is offline
Newbie Coder
 
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
You can use it between <head></head> or after starting the <body> tag.

Greetz
__________________
------------------------------------
bd_coder
Reply With Quote
  #5 (permalink)  
Old 06-16-06, 10:14 AM
Andy128 Andy128 is offline
Wannabe Coder
 
Join Date: Jun 2006
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks. I'll give it a try.

Andy
Reply With Quote
  #6 (permalink)  
Old 06-16-06, 11:09 AM
Andy128 Andy128 is offline
Wannabe Coder
 
Join Date: Jun 2006
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
**Problem with solution

Ok- That worked but............... I wanted it to open in a new browser window so that after reading the error message- they could "X" out of it and return to the form and correct their problem.

As it is- it opens in a small window like I wanted --but there is no way to get back to the form in a regluar size window. Any suggestions?

Andy
Reply With Quote
  #7 (permalink)  
Old 06-17-06, 06:14 AM
bd_coder bd_coder is offline
Newbie Coder
 
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
First of all I'm not 100% clear about what you are going to do. If you want to open your message in a new window then try this:

first place this code between <head></head> tags
Code:
<script language="javascript" type="text/javascript">
function show_popup(str)
{
  var arg = 'resizable=no, toolbar=no,location=no,directories=no,addressbar=no,scrollbars=yes,status=no,menubar=no,width=300,height=300,top=20,left=250';
  window.open(str, "_blank", arg);
}
</script>
then place this code where you want to open a new window

Code:
<script type="text/javascript">
show_popup('your-page.php');
</script>
If you want to post your data in a page which will open in a new window then use target="_blank" in your <form> tag. Then resize the window using resizeTo(300, 300).
Greetz
__________________
------------------------------------
bd_coder
Reply With Quote
  #8 (permalink)  
Old 06-18-06, 01:33 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Moving to Javascript.

Our resident Javascript Guru should be able to help.
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Reply With Quote
  #9 (permalink)  
Old 06-18-06, 05:29 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Christian
Moving to Javascript.

Our resident Javascript Guru should be able to help.
We have one of those? Strange, I don't remember seeing him around here...

Anyways, if you want to keep things simple, do like bd_coder suggested and put the target="_blank" attribute in the <form> tag. That will open the validation/submission page in a new window.
Then you need to make sure that the script
Code:
<script language="javascript">
window.resizeTo(300,300);
</script>
is placed in the <head> tag on that page (which, judging by your last post, seems to be working already).

You might also want to add some code to disable the submit button after it has been pressed to avoid double posts. And maybe re-enable it from the popup if the validation fails so it can be resubmitted.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #10 (permalink)  
Old 06-18-06, 05:35 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Quote:
Originally Posted by TwoD
We have one of those? Strange, I don't remember seeing him around here...
You should learn to take a compliment.
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools
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 On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
window size Seeker HTML/XHTML/XML 2 09-15-05 04:20 PM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
[Help] Javascript pop up window with background color empty.container JavaScript 1 01-13-05 03:11 AM
how to set minimal dimensions for a modal window jasongr JavaScript 1 09-29-04 03:25 AM
limiting size of pop-up window on Mac magda JavaScript 0 05-10-04 08:28 PM


All times are GMT -5. The time now is 11:11 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.