View Full Version : Opening to a certain size in a new window
Hi. I'm pretty new at this. Basically what I want to do is, from a link, open a page in a new window, around 200 by 100 pixels not full screen. Can anyone help me with this? Thanks :thumbsup:
- Narz
boxer_1
07-28-2002, 03:48 PM
Here's one way you could do it:
<a href="javascript:;" onClick="window.open('yourPage.html','myWin','scrollbars=yes,width=200,height=100');">Open Window</a>
For more information on pop-ups: http://tech.irt.org/articles/js205/index.htm
Hmmm, didn't work. :confused: Is there a way I could resize the window with just HTML?
Thanks,
Narz
Zvona
07-29-2002, 03:17 PM
Originally posted by Narz
Hmmm, didn't work. :confused: Is there a way I could resize the window with just HTML?
Thanks,
Narz
No, there isn't. HTML is meant for defining the structure of document, not layout nor controlling.
You can either open a new instance with JS's window.open(sUrl, sName, sProperties) method, where you set properties width & height or you can control new instance with method window.resizeTo(iX, iY).
Tutorials for these methods can be found several places in the Internet by using Google.
boxer_1
07-29-2002, 03:45 PM
Did you follow the link I posted in my first reply? Like Zvona posted, there are a lot of resources out there. There's a pop-up window generator that will create the code you need for you here: http://javascriptkit.com/popwin/index.shtml Just adjust the height and width in the generated code to suite yourself ;) .
:mad: This is really frustating. :confused: :confused:
I went to the JavaScript Popup window generator site and it gave me some code (which I added) but the code did nothing! I put it in the body of the pop-up page, do I need to add something also to the link? What names and/or values to I need to change? I'm not stupid but I know absolutely nothing about Javascript. All I want is to open one little window sized a certain way! Can anyway tell me (or direct me to a resorce that explains) what exactally to add to the link (opening the specially sized page) and to the page itself. Thanks very much! :thumbsup:
- Narz
A1ien51
07-30-2002, 06:17 AM
post your code here,,,,,i am sure you added it wrong....
boxer_1
07-30-2002, 08:47 AM
Ok, here's some code generated from the pop-up generator I provided the link for (for the purpose of this example). We'll use this as an example of how you need to set things up. First, add the following to the head section of your main page (not the page you want to load into the pop-up, but the page you want to open the pop-up from:
<script type="text/javascript">
//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts
function openpopup(){
var popurl="thankyou.htm"
winpops=window.open(popurl,"myWin","width=100,height=200,scrollbars,resizable,")
}
</script>
Change the bolded "thankyou.htm" to the page you want to load into the pop-up window. The bolded width and height are self expainatory, I set the values to 200x100 as that's what you indicated for size in your initial post. Next, place the below into the same page, this time in the body section of the page you want to open the pop-up window from:
<a href="javascript:openpopup()">Click here to open window</a>
Just for the purpose of this example, here is what you main page might look like. The page you wish to open the pop-up window from. You do not need to add any of this to the page you wish to open into the pop-up window. This is the main page (the opener):
<html>
<head>
<title>Your page, not the pop-up</title>
<script type="text/javascript">
//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts
function openpopup(){
var popurl="thankyou.htm"
winpops=window.open(popurl,"myWin","width=100,height=200,scrollbars,resizable,")
}
</script>
</head>
<body>
Your page content here... Below is the link to open your pop-up window:
<br />
<a href="javascript:openpopup()">Click here to open window</a>
</body>
</html>
If you saved the above as test.html, changed "thankyou.htm" to the page you want to open into the pop-up, and previewed it in your browser, it would open your pop-up window when you clicked "Click here to open window" Does this make things any clearer for you? :thumbsup:
Thank you boxer, that was very clearly explained, plus it worked! Much appreciated! :thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.