Reply
Javascript Help
Old 01-28-2005, 02:15 PM Javascript Help
Average Talker

Posts: 25
Hello,

We are setting up a fly by window on this site www.sanjoserealty.net. We would like to set it up so that the fly in only shows up once for each visitor. Since, this script was generated automatically for me, does anyone know of a string I can add to the code to get it to make sure that it doesn't keep popping up for the same visitor repeatedly?
fisher318 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 01-30-2005, 02:07 PM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Can you post the code?

I am looking to just add a cookie to the script.
__________________
CYTech-services.com - 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 01-30-2005, 05:40 PM
Average Talker

Posts: 25
Thanks for your help! Here is the script that I added to the page for the fly in:

PHP Code:
<script>var flyin=1;function NoFlyIn(){flyin=0}function FlyInAd(){if(flyin&&document.all)showModalDialog('http://www.sanjoserealty.net/flyindata.htm',window,'status:no; help:no');}onload=FlyInAd;</script> 
And here is the whole code to the extra page that holds the fly in code:

PHP Code:
<html><head><title>Get Your FREE Report Now!</title><script>function get_random(max){var ranNumMath.round(Math.random()*max);return ranNum;}var mode 2;if (mode == 4mode get_random(3);var windowwidth=437;var windowheight=405;var xcenter;var ycenter;var pause=20;var step=40;var shakecount=10;var pagecenter;var timer;function moveDialog(lefttop) {window.dialogLeft left "px";window.dialogTop top "px";}function resizeDialog(widthheight) {window.dialogWidth width "px";window.dialogHeight height "px";}function init() {xcenter=Math.floor(screen.width/2)-Math.floor(windowwidth/2);ycenter=Math.floor(screen.height/2)-Math.floor(windowheight/2);if (mode == 0) {windowtop ycenter;windowleft windowwidth;} else if (mode == 1) {windowtop windowheight;windowleft xcenter;} else if (mode == 2) {windowtop ycenter;windowleft screen.width;} else if (mode == 3) {windowtop screen.height;windowleft xcenter;}moveDialog(windowleftwindowtop);resizeDialog(windowwidth,windowheight
);}function showWindow() {init();
movewindow();
}function 
shake() {if (shakecount 0) {var horiz get_random(2) - 1;var vert get_random(2) - 1;windowleft xcenter horiz 5;windowtop ycenter vert 5;moveDialog(windowleftwindowtop);shakecount--;timer setTimeout("shake()"pause);} else {clearTimeout(timer);}}function movewindow() {var ok 0;if (mode == && windowleft <= xcenterok 1;else if (mode == && windowtop <= ycenterok 1;else if (mode == && windowleft >= xcenterok 1;else if (mode == && windowtop >= ycenterok 1;if (ok) {moveDialog(windowleft,windowtop);if (mode == 0windowleft+=step;else if (mode == 1windowtop+=step;else if (mode == 2windowleft-=step;else if (mode == 3windowtop-=step;timersetTimeout("movewindow()",pause)}else {clearTimeout(timer);timer setTimeout("shake()"pause);}}function doIt() {showWindow();}doIt();</script></head><body scroll=no topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><table cellpadding=0 cellspacing=0 width=100% height=100% border=0><tr><td><iframe
width=100% height=100% src="http://www.sanjoserealty.net/freereport.htm"></iframe></td></tr></table></body></html> 
fisher318 is offline
Reply With Quote
View Public Profile
 
Old 02-01-2005, 07:35 AM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Hey fisher,

Okay heres some code for ya:

Code:
//Cookies
var now = new Date(); 
fixDate(now); 
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); 
var visits = getCookie("counter"); 
if (!visits) { 
visits = 1; // the value for the new cookie
//FLYIN CODE HERE 
} else { 
visits = parseInt(visits) + 1; 
}

setCookie("counter", visits, now);
Place your flyin code in where I marked it
__________________
CYTech-services.com - 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 02-01-2005, 06:50 PM
Average Talker

Posts: 25
Ok, I placed the code as follows and then get an error on line 3 character 1 object expected. The pop up doesn't show at that point unless I say either yes or no to continuing to run scripts on that page.

PHP Code:
<html><head><title>Get Your FREE Report Now!</title><script>//Cookies
var now = new Date(); 
fixDate(now);
now.setTime(now.getTime() + 365 24 60 60 1000); 
var 
visits getCookie("counter"); 
if (!
visits) { 
visits 1// the value for the new cookie
function get_random(max){var ranNumMath.round(Math.random()*max);return ranNum;}var mode 2;if (mode == 4mode get_random(3);var windowwidth=437;var windowheight=405;var xcenter;var ycenter;var pause=20;var step=40;var shakecount=10;var pagecenter;var timer;function moveDialog(lefttop) {window.dialogLeft left "px";window.dialogTop top "px";}function resizeDialog(widthheight) {window.dialogWidth width "px";window.dialogHeight height "px";}function init() {xcenter=Math.floor(screen.width/2)-Math.floor(windowwidth/2);ycenter=Math.floor(screen.height/2)-Math.floor(windowheight/2);if (mode == 0) {windowtop ycenter;windowleft windowwidth;} else if (mode == 1) {windowtop windowheight;windowleft xcenter;} else if (mode == 2) {windowtop ycenter;windowleft screen.width;} else if (mode == 3) {windowtop screen.height;windowleft xcenter;}moveDialog(windowleftwindowtop);resizeDialog(windowwidth,windowheight
);}function showWindow() {init();
movewindow();
}function 
shake() {if (shakecount 0) {var horiz get_random(2) - 1;var vert get_random(2) - 1;windowleft xcenter horiz 5;windowtop ycenter vert 5;moveDialog(windowleftwindowtop);shakecount--;timer setTimeout("shake()"pause);} else {clearTimeout(timer);}}function movewindow() {var ok 0;if (mode == && windowleft <= xcenterok 1;else if (mode == && windowtop <= ycenterok 1;else if (mode == && windowleft >= xcenterok 1;else if (mode == && windowtop >= ycenterok 1;if (ok) {moveDialog(windowleft,windowtop);if (mode == 0windowleft+=step;else if (mode == 1windowtop+=step;else if (mode == 2windowleft-=step;else if (mode == 3windowtop-=step;timersetTimeout("movewindow()",pause)}else {clearTimeout(timer);timer setTimeout("shake()"pause);}}function doIt() {showWindow();}doIt();
} else { 
visits parseInt(visits) + 1
}

setCookie("counter"visitsnow);</script></head><body scroll=no topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><table cellpadding=0 cellspacing=0 width=100% height=100% border=0><tr><td><iframe
width=100% height=100% src="http://www.sanjoserealty.net/freereport.htm"></iframe></td></tr></table></body></html> 
fisher318 is offline
Reply With Quote
View Public Profile
 
Old 03-10-2005, 06:00 PM
kline11's Avatar
King Spam Talker

Posts: 1,262
Name: John
Location: USA
Try this:
<script language="JavaScript">
function getCookie(NameOfCookie){
if (document.cookie.length > 0) {
begin = document.cookie.indexOf(NameOfCookie+"=");
if (begin != -1) {
begin += NameOfCookie.length+1;
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end));
}
}
return null;
}

function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) {
if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

function checkIt()
{
visited=getCookie('visited');
if (visited==null)
{
setCookie('visited','yes',180)
function NoFlyIn()
}
}
</script>
kline11 is offline
Reply With Quote
View Public Profile Visit kline11's homepage!
 
Reply     « Reply to Javascript Help
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15203 seconds with 13 queries