View Full Version : Very basic pop up window script wanted
dirtystim
09-05-2001, 05:00 AM
Hi guys all I want is a VERY basic pop up window script.
I have looked for a real basic one but cant find it exactly.
I dont need ny scroll bars or any thing just a little close window button.
Um yeah I need to know how to fit it into my page too . . Coz I am dumb :(
much respect . . .
d
Dr. Web
09-05-2001, 12:49 PM
<html>
<head>
<title>Untitled</title>
<script language ="javascript">
win="";
function pop_up(){
win = window.open("http://www.yahoo.com", "dep", "height=100,width=200", hotkeys="no");
}
function closeDep() {
if (win=="undefined"){}else{
if (win.open) win.close();
}
}
</script>
</head>
<body onUnload="closeDep();">
<a href="#" onclick="pop_up();">Yahoo</a>
<br><br><br>
<a href="#" onClick="closeDep();">Close the window</a>
</body>
</html>
dirtystim
09-05-2001, 01:00 PM
Aah ... the good doctor comes correct yet again! :)
Is that one better than this one doc (this is the one i was gonna use ...)??
My one sure looks simpler but hell you the Doc!
d
PS!
Which one would load quicker Doc - I'm starting to get a little anal about load times . . . THX!!
Dr. Web
09-05-2001, 03:48 PM
both scripts will effect the load time on the millesecond level.... so no need to worry about that.
my script will close the pop-up as you leave the page, and also has a link to close the window (as you asked for). Now, a close pop-up script will generate an error if the pop-up does not exist... hence the extra chunk of code named: closeDep(). This code checks to see if the pop-up is present, and if yes then closes it.
dirtystim
09-05-2001, 06:03 PM
Thanks Doc you da man!!
Say, you know Doc, the pop up is actually to display a copyright notice, so do i want it to close on page leaving?
Or if I don't d'you think that will only serve to annoy the visitors?
Your opinion is always valued . . .
Ok that was a bit crawly :P
But thanks for the input M8! ;)
d
ps what's the 'hotkeys=no' do that sounded cool . . .
Dr. Web
09-05-2001, 06:56 PM
hotkeys are control-d or alt-a.
If you don't want it to close when you leave, or more specifically exit the website, then remove the onUnload="closeDep();" from the body tag.
Do you want it to close when they leave? yes..... because most likely they will have closed the pop-up anyway... but if not-they are done with your website (for now, anyway :D) and its always nice to clean up any pop-ups you have created.
dirtystim
09-05-2001, 08:17 PM
Rock on Doc
Thanx for the bit of Webmaster Netiquette . .
I will heed the wise wordz . .
Oh btw what (if any) metatags should i put in the source code of the pop up?
and what tags do you as a general rule use in the sites that you build?
Cheers Doc
I like this Headache just fine!
d:rocker:
dirtystim
09-05-2001, 08:51 PM
Say Doc How would I put a little close window button into
the pop up itself, I'd prefer this due to space constraints.
I also want it to be positioned centre,centre too could you give me a pointer on that too pls :)
thx muchly
d
whkoh
09-05-2001, 10:25 PM
Originally posted by dirtystim
Say Doc How would I put a little close window button into
the pop up itself, I'd prefer this due to space constraints.
I also want it to be positioned centre,centre too could you give me a pointer on that too pls :)
thx muchly
d try this:
Dr. Web
09-05-2001, 11:32 PM
I don't have the code handy for a centered pop-up... but its easy to locate on www.a1javascripts.com
heres the code to add a link to close the window IN THE POP-UP. This will not work unless its in a pop-up.
<html>
<head>
<title>Untitled</title>
</head>
<body>
<a href="#" onClick="self.close()">close me</a>
</body>
</html>
meta tags? Put whatever you like! I don't use them unless I am making a commercial site... which is hardly ever! most of my work is building web applications.... and they don't need to be indexed by the robots! Just check my pages out... no meta data. :D
dirtystim
09-06-2001, 03:10 AM
Many Thanks Doc and also Whkoh (do I pronounce that phonetically as "W-quo?")
I will rifle through some Scripts at that site, and look at the source code Whkoh attached.
Many thanks dudes! :)
d
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.