View Full Version : using javascript and windows
JaeSun
08-27-2002, 04:57 PM
ive been working on this website:
www.satworld.biz/new.shtml
and ive been looking for a javascript ... i want to make it to where, when people click a link, a whole new window comes up, but i want the new window to be a certain size, no file, edit toolbars, backbuttons, etc, just the title toolbar (that has the minimuze, close window), and the page itself ...
i cant find the scipt whatsoever. i have found some sites that have them, but forgot where they are ...
does anyone know what im talking about? click a link, window comes up, nothing but the page itself, and the title toolbar .... and the variables are controlled by the javascript in each link itself ..
any help?
thanks in advance ...
sk8hardusd
08-27-2002, 05:09 PM
<script type="text/javascript">
function openwindow()
{
window.open("http://www.url.com","my_new_window","toolbar=yes,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistor y=yes,width=whatever,height=whatever")
}
</script>
And then just choose whatever options of those you want.
JaeSun
08-27-2002, 05:13 PM
umm, how would i use that for a link?
almost looks that it will load that link when the page loads up?
sk8hardusd
08-27-2002, 05:18 PM
Whoops sorry about that.
Thank god. I just got a brain freeze and forgot how to use a link. Man I am stupid. Someone help him out.
scoutt
08-27-2002, 06:09 PM
hehe ok sure you had a brain fart, ehh we all get them sometimes. :D
with that function you can use this
<a href="javascript:openwindow()">new window</a>
JaeSun
08-27-2002, 06:12 PM
do i place the javascript code in the head or in the body?
scoutt
08-27-2002, 06:16 PM
you can put the funtion in the head and the link wherever you want.
sk8hardusd
08-27-2002, 06:17 PM
the body
scoutt
08-27-2002, 06:19 PM
generally it should go in the head, but it doesn't matter. personally I don't care for my javascript in the body (unless it has a specific purpose to be tehre) as it clutters up the code for the rest of the page.
sk8hardusd
08-27-2002, 06:22 PM
I haven't had too many sites that were very in depth, so it doesn't clutter the rest of the code for me too bad.
JaeSun
08-27-2002, 06:24 PM
if i put the main code in the head, but dont call it in the body (the link part of the code), will it give me an error in the page?
cuz im using SSI for most of the header code (except the page titles), and only half the pages will use this code...so dont want to put it in the header code if it gonna give me the error message ...
JaeSun
08-27-2002, 06:26 PM
well, i like to keep clean websites if possible, makes it easy for upgrading, etc ... and looks better ...hehe
scoutt
08-27-2002, 06:28 PM
jsut a regular function won't if. so you can have it in the header and it shouldn't give you any trouble.
JaeSun
08-27-2002, 06:29 PM
i also notice the :o in the code....
is it the :.o (without the . )?
scoutt
08-27-2002, 06:36 PM
yeah sorry it does it by itself. it should be
javascript:openwindow()
JaeSun
08-27-2002, 11:03 PM
ok, also, how can i make the popup come up in the center of the window, rather than the top-left ?? anyone?
scoutt
08-28-2002, 01:13 AM
http://www.snippetlibrary.com/code.php?id=5&kid=20&catname=Popups
JaeSun
08-28-2002, 01:26 AM
i dont know what it is, but your codes giving me errors, or wont work ... heh?
Dr. Web
08-28-2002, 01:53 AM
Scoutt, JaeSun,
the 'f' of the word FUNCTION was capitalized, and will not properly declare a function that way. Heres the changed code...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title><!---Head--->
<script>
function resize() {
h=(window.screen.availHeight * 2/3);
w=(window.screen.availWidth * 2/3);
t = (screen.Width) ? (screen.Width-w)/2 : 0;
l = (screen.height) ? (screen.height-h)/2 : 0;
resizeTo(w,h)
moveTo(t,l)
}
</script>
</head>
<body onLoad="resize()";>
</body>
</html>
scoutt
08-28-2002, 08:49 AM
thanks guys, for some strange reason they get capitolized and I can't figure it out. I thought I got all of them.
JaeSun
08-28-2002, 11:05 AM
scott, has it been changed? ill go try it again ... then ill come back with some questions, prob later on tonight when i get home from work ... thanks!
scoutt
08-28-2002, 11:36 AM
yes it has. the one Doc posted is the same one.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.