View Full Version : onload modal window (IP Based)
TheJoshMan
10-22-2008, 11:17 PM
Here's what i'm basically looking for...
Something like this: http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm
but I want it to load up as soon as the page loads (without having to click anything). I'm sure that part is simple enough, but I also want it to ONLY load once for each IP address that visits the site.
Is this possible? I mean, I'm 100% sure it's possible, but is it far too complex for a "non-scripting" kinda guy like me to understand?
This script does open as soon as the page loads. And its not possible unless you wanna use files or a database. You could also use cookies, but then if they clear they're cookies it would be there.
TheJoshMan
10-23-2008, 12:07 AM
yea, php and/or database is fine. I suppose it would be ok to use cookies, but I'm afraid that users might get annoyed if they see the message mroe than once, that's why i only wanted to use the IP
Medyman
10-23-2008, 01:17 AM
yea, php and/or database is fine. I suppose it would be ok to use cookies, but I'm afraid that users might get annoyed if they see the message mroe than once, that's why i only wanted to use the IP
I would use cookies for this. It's all client-side and would work in most situations. Sure, someone may clear their cookies but then they probably understand that their preferences are wiped clean across websites.
IP isn't a very accurate technology. You would exclude a lot more people and perhaps not show it to all visitors.
TheJoshMan
10-23-2008, 01:19 AM
ah, ok... do you have any ideas as to how to implement something like the link i posted but use cookies to control it's display?
Medyman
10-23-2008, 01:33 AM
Yeah, I've done it a few times. But, I just jQuery.
My modal window script of choice is Facebox (http://famspam.com/facebox). And I accompany that with jQuery Cookie (http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/).
The jQuery might look something like this (very crude but you'll get the idea).
$.cookie('the_cookie', 'the_value'); // set cookie
if ($.cookie('the_cookie')) {
/* do something */
}
Easy enough for ya? You really gotta learn jQuery man. It's a life saver!
TheJoshMan
10-23-2008, 01:40 AM
wow...
well, i can see this is going to be an "all nighter" for me.
My javascript skills are minimal at best. LOL
Facebox won't be a problem as i've used it before... but the jQuery cookie looks more complex than what i'm used to dealing with. (i've never even used cookies) LOL
Medyman
10-23-2008, 02:00 AM
It's really not as hard as you think. My JavaScript skills are minimal as well. But I can hack my way through jQuery. It kind of saves my face and prevents me from really understanding JS.
It's really not that difficult. I gave you most of the script above :) It would seriously just be a few lines.
jQuery(document).ready(function($) {
if ($.cookie('the_cookie')) {
alert("cookie is loaded");
}
else {
$('a[rel*=facebox]').facebox()
$.cookie('the_cookie', 'the_value'); // set cookie
}
})
The scripts do all of the heavy lifting for you. Note that the above is just theory. There is probably something wrong with it. But you get the idea.
TheJoshMan
10-23-2008, 02:02 AM
well, i'll work/play with it tonight and post up solution (if i find one) tomorrow
Thanks so much medyman, i appreciate the help.
Excuse me, don't mean to interrupt. But the script you linked to gives exactly what you want!
TheJoshMan
10-23-2008, 02:08 AM
LOL, i know Nile, I just have to figure out how to implement the cookie with the script so that it will only show that modal window once per cookie.
It's already done for you! Look at the script!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.