Цитата:
const day = (new Date()).getDay(); let html = '<p>INFORMATION</p>'; if (day) html = day + '.dat'; alert(html) |
может кому пригодиться
<script language="JavaScript">
nowDate=new Date();
theDay=nowDate.getDay();
text=new Array(30);
text[0]="7777777";
text[1]="11111111";
text[2]="2222222";
text[3]="3333333";
text[4]="4444444";
text[5]="555555555";
text[6]="66666666666";
document.write(text[theDay]);
</script>
может кому пригодиться document.write:victory: |
Цитата:
|
на хостинге не работает
на денвере работает :dance:
а на хостинг закачиваю и приехали :-?
window.addEventListener('DOMContentLoaded', function()
{
const day = (new Date()).getDay();
let html = '<p>0000000</p>';
if (day) html = day + '.dat';
if (!day || day == 4) info = html;
function get_file(url, callback)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
callback(xmlhttp.responseText);
}
}
xmlhttp.send();
}
get_file(info, function(response)
{
document.getElementById("output").innerHTML=response
})
}
);
это я пробовал и так и так ее :-E а она ни в какую просто вывод текста то работает, а из файлов тока на локалке |
ага понял почему: 1.txt читает, а вот если расширение *.dat = то на сервере прочитать не может.
|
ам, не работает воскресенье
window.addEventListener('DOMContentLoaded', function()
{
const day = (new Date()).getDay();
let html = '<p>INFORMATION</p>';
if (day) html = day +'.txt';
readTextFile(html);
}
);
не работает когда воскресенье |
не фуричит с воскресеньем
function readTextFile(file)
{
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, false);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;
document.getElementById("output").innerHTML=allText;
}
}
}
rawFile.send(null);
}
window.addEventListener('DOMContentLoaded', function()
{
const day = (new Date()).getDay();
let html = '<p>INFORMATION</p>';
if (day) html = readTextFile('admin/text/week/' + day + '.txt');
readTextFile(html);
}
);
|
как правильно вписать скрипт? сюда?
window.addEventListener('DOMContentLoaded', function()
{
}
этот скрипт:
ball.onmousedown = function(event)
{
let shiftX = event.clientX - ball.getBoundingClientRect().left;
let shiftY = event.clientY - ball.getBoundingClientRect().top;
ball.style.position = 'absolute';
ball.style.zIndex = 1000;
document.body.append(ball);
moveAt(event.pageX, event.pageY);
function moveAt(pageX, pageY)
{
ball.style.left = pageX - shiftX + 'px';
ball.style.top = pageY - shiftY + 'px';
};
function onMouseMove(event)
{
moveAt(event.pageX, event.pageY);
};
document.addEventListener('mousemove', onMouseMove);
ball.onmouseup = function()
{
document.removeEventListener('mousemove', onMouseMove);
ball.onmouseup = null;
};
};
ball.ondragstart = function()
{
return false;
};
если скрипт движения картинки установить наверх то картинка перестает двигаться. |
т.е. я понимаю что нужно дождаться загрузки скрипта: но как я вставляю сюда
window.addEventListener('DOMContentLoaded', function()
скрипт все перестает работать. т.е. window.addEventListener -> дожидается когда загрузиться страница, но не когда я нажму на мышку. |
| Часовой пояс GMT +3, время: 17:19. |