View Full Version : Anyone say "popup"

01-31-2006, 04:38 AM
Hey all im quite proud of writing my first java script.
dreamweaver could not preform what i wanted, so build from raw code.

thought i'd post it here as i remember ppl asking about this some time ago

the script
function newWindow(myUrl,w,h,features) {
var settings = "";
if (screen.width) {
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
} else {
winl = 0;
wint = 0;
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl;
if (features != "") settings += ',' + features;
myWin = window.open(myUrl,"myWin",settings);
return myWin;

function init() {
var myWin = newWindow("YOUR_PAGE_NAME.html", 300, 250, "resizable=no,scrollbars=no,toolbar=no,menubar=no,l ocation=no,statusbar=no");

then in the site where you want the pop up to appear add
<body onload="init();">

i made this pop up to come in the center of the screen with options such as no toolbar, non-resizable, no location, no status bar and no scrollbar.

then in the pop-up html page call the js
<script src="common/scripts/popup.js" type="text/javascript"></script>

you can have whatever u like in the pop-up window, a flash object, images or some sort of monthly promotional thing

i know pop-ups can be very annoying, but can also be a more direct way of getting ppl's attention (by shoving it in their face, your bound to get a reaction--- yes i kno maybe negative aswel)

could make it into a mini tut C.I. anyways ppl - EnjoyA!

01-31-2006, 12:37 PM
I wrote a quick, accessible way of doing the same thing some months ago:

01-31-2006, 10:31 PM
oh dont i suck. my bad

02-01-2006, 09:07 AM
Nice lorry.... :D

02-01-2006, 12:52 PM
oh dont i suck. my bad
lol . why? :)