Архив

Архив раздела ‘Javascript’
$(document).ready(function () {
	$('iframe').each(function() {
		var url = $(this).attr("src");
		$(this).attr("src",url+"?wmode=opaque");
	});
});
Categories: Javascript Tags:

В раздел инициализации tinymce добавить:

extended_valid_elements:"iframe[src|width|height|name|align]",
Categories: Javascript Tags: ,

Для перехода по ссылке не в iframe а на родительскую страницу:

onclick='parent.$.colorbox.close();window.parent.location.href="/contacts/";'
Categories: Javascript Tags: ,
7 июня 2012 1 комментарий
function blink(selector) {
	$(selector).fadeOut('slow',function() {
		$(this).fadeIn('slow',function() {
			blink(this);
		});
	});
}
$(document).ready(function () {
	blink('.bl');
});
Categories: Javascript Tags:
function fix_flash() {
	var embeds = document.getElementsByTagName('embed');
	for(i=0; i<embeds.length; i++)  {
		embed = embeds[i];
		var new_embed;
		if(embed.outerHTML) {
			var html = embed.outerHTML;
			if(html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i))
			new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i,"wmode='transparent'");
			else 
			new_embed = html.replace(/<embed\s/i,"<embed wmode='transparent' ");
			embed.insertAdjacentHTML('beforeBegin',new_embed);
			embed.parentNode.removeChild(embed);
		} else {
			new_embed = embed.cloneNode(true);
			if(!new_embed.getAttribute('wmode') || new_embed.getAttribute('wmode').toLowerCase()=='window')
			new_embed.setAttribute('wmode','transparent');
			embed.parentNode.replaceChild(new_embed,embed);
		}
	}
	var objects = document.getElementsByTagName('object');
	for(i=0; i<objects.length; i++) {
		object = objects[i];
		var new_object;
		if(object.outerHTML) {
			var html = object.outerHTML;
			if(html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
			new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i,"<param name='wmode' value='transparent' />");
			else 
			new_object = html.replace(/<\/object\>/i,"<param name='wmode' value='transparent' />\n</object>");
			var children = object.childNodes;
			for(j=0; j<children.length; j++) {
				if(children[j].getAttribute('name').match(/flashvars/i)) {
					new_object = new_object.replace(/<param\s+name\s*=\s*('|")flashvars('|")\s+value\s*=\s*('|")[^'"]*('|")\s*\/?\>/i,"<param name='flashvars' value='"+children[j].getAttribute('value')+"' />");
				}
			}
			object.insertAdjacentHTML('beforeBegin',new_object);
			object.parentNode.removeChild(object);
		}
	}
}
$(document).ready(function () {
	fix_flash();    
});

http://www.developersnippets.com/2010/12/04/how-to-add-wmodetransparent-for-flash-object-using-jquery-and-native-javascript/
http://www.onlineaspect.com/2009/08/13/javascript_to_fix_wmode_parameters/

Categories: Javascript Tags:

Z-index для flash-элементов

$("embed").attr("wmode", "opaque");
$(document).ready(function() {
	var embedTag;
	$("embed").each(function(i) {
		embedTag = $(this).attr("outerHTML");
		if ((embedTag != null) && (embedTag.length > 0)) {
			embedTag = embedTag.replace(/embed /gi, "embed wmode=\"opaque\" ");
			$(this).attr("outerHTML", embedTag);
		}
	});
});

http://labs.kaliko.com/2009/11/change-wmode-with-jquery.html
Не работает в IE

Categories: Javascript Tags:
17 февраля 2012 Нет комментариев

Если нужен автофокус по id:

function FieldAutoFocus() {
	document.getElementById('fieldid').focus();
}
window.onload=FieldAutoFocus;

Автофокус в первый input:

function FirstInputFocus() {
	document.getElementsByTagName('input')[0].focus();
}
window.onload=FirstInputFocus;

Усложняем. Если более 4 input на странице, то автофокус в 4-й (нумерация с 0), иначе в первый:

function InContentFormFocus() {
	if (document.getElementsByTagName('input')[4]!=undefined) {
		document.getElementsByTagName('input')[3].focus();
	}
	else {
		document.getElementsByTagName('input')[0].focus();
	}
}
window.onload=InContentFormFocus;
Categories: Javascript Tags: