Задача присвоить нужному option атрибут selected.
var sel=document.getElementById('selectid'); sel.options[10].setAttribute("selected","selected");
Специально для firefox добавляем строчку:
sel.options[10].selected=true;
Задача присвоить нужному option атрибут selected.
var sel=document.getElementById('selectid'); sel.options[10].setAttribute("selected","selected");
Специально для firefox добавляем строчку:
sel.options[10].selected=true;
Функция возвращает размеры рабочей области окна и размеры загруженной страницы сайта:
function getPageSize(){ var xScroll, yScroll, pageWidth, pageHeight, windowWidth, windowHeight; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode xScroll = document.documentElement.scrollWidth; yScroll = document.documentElement.scrollHeight; } else { // Explorer Mac...would also work in Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } return [pageWidth,pageHeight,windowWidth,windowHeight]; }
Источник: http://www.jstoolbox.com/skripty/raznoe/poluchenie-razmera-stranicy/
Использование — в примере alert, когда высота страницы больше высоты рабочей области окна, т.е. есть вертикальная полоса прокрутки:
перед закрытием body
<script type="text/javascript"> var ps=getPageSize(); if (ps[1]>ps[3]) { alert(">"); } </script>
Для новых записей — в настройках обсуждения. Для всех, ранее созданных — в phpmyadmin:
UPDATE `wp_posts` SET `ping_status`='closed';
Отправляя
header("HTTP/1.0 404 Not Found"); exit();
в .htaccess
ErrorDocument 404 /404.php
работать не будет.
Можно отправлять заголовок
header("Location:/404.php");
но тогда ответ будет HTTP/1.1 302 Moved Temporarily
Решение: содержимое файла 404.php переносим в функцию
function Print404() { echo '<h1>404</h1><a href="/">back</a>'; }
и в коде:
header("HTTP/1.0 404 Not Found"); Print404(); exit();
order_from
и order_to
— массивы, содержащие значения дней, месяцов и лет периодов.
На выходе:
order_days
— интервал в днях;budn
— количество будней;vyh
— количество выходных.var time_from=new Date(order_from['y'],order_from['m']-1,order_from['d']); var time_to=new Date(order_to['y'],order_to['m']-1,order_to['d']); var order_days=Math.floor((time_to.getTime()-time_from.getTime())/(1000*60*60*24)); var getday=new Date(); var vyh=0; var curday; for (i=0;i<=order_days;i++) { //getday.setDate(time_from.getDate()+i); getday.setTime(time_from.getTime()+((1000*3600*24)*i)); curday=getday.getDay(); if ((curday==0)||(curday==6)) { vyh++; } } var budn=order_days; budn=budn-vyh;
Имеется 3 select: день, месяц и год.
Задача: перезагружать select с днями в зависимости от выбранного месяца, и года — для того чтобы узнать количество дней в феврале (високосный год или нет).
В примере часть javascript, отвечающая непосредственно за перезагрузку, как рисовать сами селекты и т.д. должно быть понятно.
var order_from=new Array; var order_from_y=document.getElementById('calc_from_y'); order_from['y']=order_from_y.options[order_from_y.selectedIndex].value; var order_from_m=document.getElementById('calc_from_m'); order_from['m']=order_from_m.options[order_from_m.selectedIndex].value; var order_from_d=document.getElementById('calc_from_d'); order_from['d']=order_from_d.options[order_from_d.selectedIndex].value; var days_in_month=new Array(31,28,31,30,31,30,31,31,30,31,30,31); if ((order_from['y']%4==0)&&(order_from['m']==2)){ days_in_month[1]++; } if (order_from_d.length>days_in_month[order_from['m']-1]) { order_from_d.length=days_in_month[order_from['m']-1]; } else { for(i=order_from_d.length+1;i<=days_in_month[order_from['m']-1];i++) { order_from_d.options[order_from_d.options.length] = new Option(i,i); } }
15 — id документа.
Core_Entity::factory('Document', 15)->Document_Versions->getCurrent()->execute();