PDA

View Full Version : Popup on every page of my site


stathis
08-11-2003, 03:31 AM
Hello guys!

I need to put an urgent announcement on my website, that i need it to appear as a popup in every page of the website. Is there a way i can do it with javascript without having to put the code in every single page?
Or is there any other way i can do this?
Thanks

agent002
08-11-2003, 06:34 AM
You could put the code into a .js file, but you'll have to include the .js file anyways. Just as a tip, already when you start designing your site, it's good to include an empty .js on every page. Then, when you need that popup, you already have the .js included and you only need to add the code to the .js.

Goldilocks
08-11-2003, 06:51 AM
Also, if you use server-side include files for your menus, then you could put the code in there so you only have to do it the once. That would also work if you use frames.

stathis
08-11-2003, 08:19 AM
Thanks guys, you are most helpful. Can you please help me on something else?

I have this popup script.

<script language="Javascript">
function nastyPopUp(height, width, scrollbars) {
var poppy;
var opts =
"toolbar=no,status=no,location=no,menubar=no,resizable=no";
opts += ",height=" + height + ",width=" + width +
",scrollbars=" + scrollbars;

poppy = window.open("notfound.html","",opts)
poppy.focus();
return false
}
</script>


=====================
<body onload="nastyPopUp(200,200,'no')"

How do i center this popup in the middle of the screen?

tarundhillon
08-11-2003, 09:33 AM
hey just try this
poppy = window.open("notfound.html","thewindow",opts)
it should come in the center by default

stathis
08-11-2003, 09:46 AM
nope. Still in the same place :(

stathis
08-11-2003, 10:13 AM
OK i got it. For anyone interested, the script code has to change like this to center the popup windows

<script language="Javascript">
function nastyPopUp(popwidth, popheight, scrollbars) {
var winleft = (screen.width - popwidth) / 2;
var winUp = (screen.height - popheight) / 2;
var poppy;
var opts =
"toolbar=no,status=no,location=no,menubar=no,resizable=no";
opts += ",width=" + popwidth + ",height=" + popheight + ",left=" + winleft + ",top=" + winUp + ",scrollbars=" + scrollbars;

poppy = window.open("announcement.html","",opts)
poppy.focus();
return false
}

</script>

tarundhillon
08-11-2003, 10:13 AM
Syntax

oNewWindow = window.open( [sURL] [, sName] [, sFeatures] [, bReplace])
Parameters


sFeatures Optional.

left = number Specifies the left position, in pixels. This value is relative to the upper-left corner of the screen. The value must be greater than or equal to 0.

top = number Specifies the top position, in pixels. This value is relative to the upper-left corner of the screen. The value must be greater than or equal to 0.
width = number Sets the width of the window, in pixels. The minimum value is 100.

give the top and left values and then try

tarundhillon
08-11-2003, 10:24 AM
hey both of us got at the same time
8:43

stathis
08-11-2003, 02:24 PM
cool :)