JS popup troubles
- Started
- Last post
- 12 Responses
- elwolverton
Does anyone know the Javascript code that makes a popup window appear when someone clicks on a specifict link?
i.e. they are at a homepage, and when they click the "gallery" button, a popup window appears as well?
I know popups are totally evil, but a client really really wants one.
- TResudek0
Easiest way to do it:
In the page you want the pop-up to come from (in your example that'd be the gallery page), put this in the tag,
onLoad="launch();"
Then in the use this:
function launch() {
winURL = "yourURL";
winName = "PopWin";
winWidth = 320;
winHeight = 440;
winOffX = (screen.width - winWidth - 22)/2;
winOffY = (screen.height - winHeight)/2 - 50;
winSpecs = "width=" + winWidth + ",height=" + winHeight + ",toolbar=0,menubar=0,scrollbars... + winOffX + ",top=" + winOffYPopWin = window.open(winURL,winName,winSp...
}That'll make it pop-up in the middle of the screen. Just change the URL and the size and you're golden.
TR
- elwolverton0
Thank you. You make non-stop rocking possible.
- elwolverton0
Ok, after closer inspection, I actually need the script to launch the popup from the index page, rather than the page that the link is trying to go to.
Any ideas?
I see that http://www.emyth.com does this well, but their code's pretty convoluted.
- JazX0
I have some at my site, just go to Loopkit.com and download the entire site, the JS is there with it.
- JazX0
http://tech.irt.org/articles/js1… that was pretty easy with Google
- JazX0
the second thing that came up on Google.com: http://javascript.internet.com/g… you need some more? ;)
- TResudek0
They are just using OnUnLoad="DisplayInfo()"
This makes the pop-up come up anytime you leave the index page. Not very smart if you ask me but if that is what you want to do, just put that onUnLoad into your tag.
TR
- JazX0
hahahaa mitsu hehehee ;)
- elwolverton0
where would i put that OnUnLoad tag? in the body tag for the index page? because it aint really working when i check it in safari...
- elwolverton0
It's likely that this thread is only met with apathy by now, but just in case not:
None of those solutions have worked, for some reason. The OnUnLoad item is very interesting, but it isn't cooperating.
- elwolverton0
Nevermind! You're totally right. Unload worked like a charm. It was just wrestling with another script I had in the tag. Thanks a bunch guys. Great little gif image, too : )