0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
function is_ie8(){
var ua = navigator.userAgent.toLowerCase();
var is_opera = ua.indexOf("opera") != -1;
var is_opera5 = ua.indexOf("opera/5") != -1 || ua.indexOf("opera 5") != -1;
var is_opera6 = ua.indexOf("opera/6") != -1 || ua.indexOf("opera 6") != -1;
var is_opera7 = ua.indexOf("opera/7") != -1 || ua.indexOf("opera 7") != -1;
var is_opera8 = ua.indexOf("opera/8") != -1 || ua.indexOf("opera 8") != -1;
var is_opera9 = ua.indexOf("opera/9") != -1 || ua.indexOf("opera 9") != -1;
var is_opera95 = ua.indexOf("opera/9.5") != -1 || ua.indexOf("opera 9.5") != -1;
var is_opera96 = ua.indexOf("opera/9.6") != -1 || ua.indexOf("opera 9.6") != -1;
var is_opera95up = is_opera95 || is_opera96;
var is_ff = ua.indexOf("firefox") != -1 && !is_opera;
var is_gecko = ua.indexOf('gecko') != -1 && !is_opera;
var is_chrome = ua.indexOf('chrome') != -1;
var is_safari = ua.indexOf('applewebkit') != -1 && !is_chrome;
var is_ie = ua.indexOf("msie") != -1 && !is_opera;
var is_ie4 = is_ie && ua.indexOf("msie 4") != -1;
var is_ie5 = is_ie && ua.indexOf("msie 5") != -1;
var is_ie50 = is_ie && ua.indexOf("msie 5.0") != -1;
var is_ie55 = is_ie && ua.indexOf("msie 5.5") != -1;
var is_ie5up = is_ie && !is_ie4;
var is_ie6 = is_ie && ua.indexOf("msie 6") != -1;
var is_ie6up = is_ie5up && !is_ie55 && !is_ie5;
var is_ie7 = is_ie && ua.indexOf("msie 7") != -1;
var is_ie7up = is_ie6up && !is_ie6;
var is_ie7down = is_ie7 || is_ie6 || is_ie5 || is_ie4;
var is_ie8 = is_ie && ua.indexOf("msie 8") != -1;
var is_ie8up = is_ie8 && !is_ie7down;
if (is_ie && !is_ie8up && !is_ie8) {
return true;
}else return false;
}
Детектим IE8
deraider ,
05.03.2010 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
function ShowButton(name, link, target,img,id,style){
{/<TD align = "right" width=1>/}
{/<SPAN id=" %id " title=" %name " style=" %style ">/}
{/<TABLE style="CURSOR: pointer" height=16 cellSpacing=0 cellPadding=0 border=0>/}
{/<TBODY>/}
{/<TR height=3>/}
{/<TD vAlign=top width=7><IMG height=3 src=" %pPath() left_top_button" width=7 border=0></TD>/}
{/<TD class=spacer vAlign=top background= %pPath() bg_top_button> </TD>/}
{/<TD vAlign=top width=7><IMG height=3 src=" %pPath() right_top_button" width=7 border=0></TD></TR>/}
{/<TR style="CURSOR: pointer">/}
{/<TD class=spacer vAlign=top width=7 background= %pPath() left_button> </TD>/}
{/<TD onClick = " %link " class=buttonLink vAlign=center noWrap align=middle background= %pPath() bg_button>/}
if(img!=null){
Image(img, null, null, null, name);
}else{
{/<a href=#> %name </a>/}
}
{/</TD>/}
{/<TD class=spacer vAlign=top width=7 background= %pPath() right_button> </TD></TR>/}
{/<TR style="CURSOR: pointer" height=3>/}
{/<TD class=spacer vAlign=top width=7><IMG src=" %pPath() left_bot_button" border=0></TD>/}
{/<TD class=spacer background= %pPath() bg_bot_button height=3> </TD>/}
{/<TD class=spacer vAlign=top width=7><IMG src=" %pPath() right_bot_button" border=0></TD></TR>/}
{/</TBODY>/}
{/</TABLE>/}
{/</SPAN>/}
{/</TD>/}
}
Из одной говносистемы документооборота:
вот из этого километра говноразметки - получается обычная кнопочка, почти ничем не отличающаяся от input type="button"
GeX ,
04.03.2010 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11
function smla(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':)';}
function smls(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='>( ';}
function smld(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':D';}
function smlf(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='B)';}
function smlg(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='%)';}
function smlh(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':(';}
function smlj(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':o';}
function smlw(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='^_^';}
function smlk(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='<_<';}
function smll(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=';)';}
function smlq(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':p';}
Ещё один китаец. Вставляет смайлы в текстовое поле вот таким вот кодом. Источник — http://mirtorrent.ru/css/pppm.js
Infamous ,
03.03.2010 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
function check_date() {
var message = "Дата невалидна.";
days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var str = $('#registration-form [name="birthday"]').val();
var m = str.match(/(\d*)\.(\d*)\.(\d*)(.*)/);
if (!m ||
!m[1] ||
!m[2] ||
!m[3] ||
m[4] ||
parseInt(m[2], 10) < 1 ||
parseInt(m[2], 10) > 12 ||
parseInt(m[1], 10) < 1 ||
parseInt(m[1], 10) > days[parseInt(m[2], 10)-1] ||
parseInt(m[3], 10) < 1920 ||
parseInt(m[3], 10) > 2000 ) {
tooltip($('#registration-form [name="birthday"]').get(0), message);
} else {
removett($('#registration-form [name="birthday"]').get(0));
}
}
Не очень говно, но вполне себе код.
ixth ,
03.03.2010 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
function BOOK_list() {
document.getElementById('rbLoadedId_list').style.display='block';
document.getElementById('rbLoadedId_blogs').style.display='none';
document.getElementById('rbLoadedId_free').style.display='none';
document.getElementById('rbLoadedId_add').style.display='none';
document.getElementById('rbLoadedId_friend').style.display='none';
document.getElementById('rbLoadedId_award').style.display='none';
document.getElementById('0rbLoadedId_list').className='act';
document.getElementById('0rbLoadedId_blogs').className='book';
document.getElementById('0rbLoadedId_free').className='book';
document.getElementById('0rbLoadedId_add').className='book';
document.getElementById('0rbLoadedId_friend').className='book';
document.getElementById('0rbLoadedId_award').className='book';
}
function BOOK_blogs() {
document.getElementById('rbLoadedId_list').style.display='none';
document.getElementById('rbLoadedId_blogs').style.display='block';
document.getElementById('rbLoadedId_free').style.display='none';
document.getElementById('rbLoadedId_add').style.display='none';
document.getElementById('rbLoadedId_friend').style.display='none';
document.getElementById('rbLoadedId_award').style.display='none';
document.getElementById('0rbLoadedId_list').className='book';
document.getElementById('0rbLoadedId_blogs').className='act';
document.getElementById('0rbLoadedId_free').className='book';
document.getElementById('0rbLoadedId_add').className='book';
document.getElementById('0rbLoadedId_friend').className='book';
document.getElementById('0rbLoadedId_award').className='book';
}
JS-табы по-китайски. Взято отсюда — http://vkurse.net.ru/js/info.js
Это только первые 2 функции, в источнике ещё больше
Infamous ,
03.03.2010 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12
function trim(text) {
if (text.length == 0) {
return text;
}
if (text.charAt(0) == ' ') {
return '';
}
if (text.charAt(text.length-1) == ' ') {
text = text.substring(0, text.length-1);
}
return text;
}
суровый китайский trim...
ClintEastwood ,
02.03.2010 (Updated 24.03.2018 )
0
1
<body onload="blinkAfterSearch();setTimeout('loadDummyImg()', 590000);var ex; try { startUpTasks(); } catch(ex) {}" />
Недавно отрыл в недрах нашего проекта! Try catch в onload!! :D
jericho ,
02.03.2010 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
var Scroller = function (scroll_left,scroll_right,visible_part,scroll_part) {
this.scroll_right = jQuery(scroll_left); //scroll to left
this.scroll_left = jQuery(scroll_right); //scroll to right
this.slider = jQuery(scroll_part); //scroll element
this.visible_part = jQuery(visible_part);
this.width_slider_elements = this.slider.width();
this.width_slider_element = this.slider.find('li:eq(0)').width();
this.width_visible_part = this.visible_part.width();
this.temp_process = true;
if(this.width_slider_elements < this.width_visible_part) {temp_process = false;}
var self = this;
this.scroll_left.click(function()
{
if (self.temp_process) {
self.temp_process = false;
self.slide(true);
}
return false;
});
this.scroll_right.click(function()
{
if (self.temp_process) {
self.temp_process = false;
self.slide(false);
}
return false;
});
return this;
};
Scroller.prototype.slide = function (side) {
var self = this;
var shift = (self.width_visible_part - self.width_slider_element)/2;
var current_shift = Math.abs(self.slider.css('left').replace('px',''));
if (side) { //left
shift = (current_shift+shift+self.width_visible_part) > self.width_slider_elements ? self.width_slider_elements - current_shift - self.width_visible_part : shift;
self.slider.animate({left: '-='+shift+'px'}, 1000, function(){ self.temp_process = true;});
} else { //right
shift = shift > current_shift ? current_shift : shift;
self.slider.animate({left: '+='+shift+'px'}, 1000, function(){ self.temp_process = true;});
}
return shift;
};
Areks ,
01.03.2010 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9
function setTabs() {
for(var i = 0; i < tabsNum; i++) {
if(i === currentTab) {
$("#tabCont" + i).css("display","block");
} else {
$("#tabCont" + i).css("display","none");
};
};
};
Нашел отличную функцию для скрытия/открытия табов
Rpsl ,
01.03.2010 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11
<form name='change_form'
enctype='multipart/form-data'
method='post'
onSubmit='if (!checkfilled(document.change_form,"name")) return false;
if (!checkfilled(document.change_form,"email")) return false;
if (!checkfilled(document.change_form,"text")) return false;
if (!checkfilled(document.change_form,"company")) return false;
if (!checkfilled(document.change_form,"phone")) return false;
if (!checkint(document.change_form,"city_code", -2147483648, 2147483648)) return false;
'
action='/request/?do=add'>
Гениальное решение для проверки html-формы.
wwwguru ,
28.02.2010 (Updated 24.03.2018 )