/    Sign up×
Community /Pin to ProfileBookmark

page auto-expire does not work

Greetings, The Expire HTML page java script does not seem to work either live or local. There is nothing to say WHERE in the <BODY> to place the script, what to do with the orriginal <BODY> tag or if it needs to be split up. I need to be able to auto-expire or auto-delete a page on a specific date. Do I need to change anything in the script other than the GOLIVE and EXPIRE date? Is there an EXAMPLE or a better way???
— Thanks Wolfman7h

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@pyroJan 11.2003 — If I understand you correctly, you want to remove a page from your server at a specific time. Correct? If so, you will have to use some server side language (PHP, Perl), as javascript can't write to/delete files. Is that what you want to do?
Copy linkTweet thisAlerts:
@wolfman7hauthorJan 11.2003 — I refer to the following script:

<!--

Script Name: Auto Expire

Website URL: http://javascript.internet.com/calendars/auto-expire.html

Description: Content will only be displayed between the 'Go Live' date and the 'Expires' date. Great for promotions that start on a certain date, and end on another date.

-->

<!-- ONE STEP TO INSTALL AUTO EXPIRE:

1. Copy the coding into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the BODY of your HTML document -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

// Set the dates below

var goLiveDate = "20011015";

var expireDate = "20101015";

var expireYear = expireDate.substring(0,4)

var expireMonth = expireDate.slice(4,-2)

var expireDay = expireDate.slice(6)

var liveYear = goLiveDate.substring(0,4)

var liveMonth = goLiveDate.slice(4,-2)

var liveDay = goLiveDate.slice(6)

var nowDate = new Date();

var day = nowDate.getUTCDate();

var month = nowDate.getUTCMonth();

var month1 = month + 1;

if (month1 < 10)

{

month1 = "0" + month1;

}

if (day < 10)

{

day = "0" + day;

}

var year = nowDate.getYear();

var GMTdate = year + "" + month1 + "" + day

if ((GMTdate < expireDate) && (GMTdate >= goLiveDate))

{

// Insert the text you want displayed below

document.write("<div align='center'><b>This content appeared on " + liveMonth + "/" + liveDay + "/" + liveYear + "<br>and will disappear on " + expireMonth + "/" + expireDay + "/" + expireYear +".</b></div>")

}

// End -->

</script>
Copy linkTweet thisAlerts:
@pyroJan 11.2003 — All that script will do is print the text that says what date the page went online (the first date you set) and the page it expires (the second date you set). It won't automatically remove the page once the second date is reached. Like I said before, you would need some server side language to do that.
×

Success!

Help @wolfman7h spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...