Home >Web Front-end >JS Tutorial >JavaScript scheduled display advertising code sharing_javascript skills

JavaScript scheduled display advertising code sharing_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:11:491148browse

This is a javascript code that displays advertisements at a scheduled time. Of course, it can also display a certain block of content at a scheduled time, which is very practical.

The code is as follows:

Copy code The code is as follows:

function strToDate(str, ext) {
if (str == null || str == '') return;
var arys = new Array();
arys = str.split('-');
var newDate = new Date(arys[0], arys[1] - 1, arys[2], 9, 0, 0);
if (ext) {
newDate = new Date(newDate.getTime() 1000 * 60 * 60 * 24);
}
return newDate;
}
function showit(str, start, end) {
var date = new Date();
var start = strToDate(start);
var end = strToDate(end, false);
if (date & gt; start & amp; & amp; date document.write(str);
}
}

Retrieval:
Copy code The code is as follows:

showit('Your ads','2011-07-06','2011-07-18');
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn