搜索

‘return false’ vs ‘e.preventDefault()’

0413

介绍下’return false’和’event.preventDefault()’之间的不同开始,先知道preventDefault() preventDefault() 定义 取消事件的默认动作。 比如<a href=”http://www.funnyapple.com>Jessica</a>,默认行为是跳转链接到http://www.funnyapple.com。那么preventDefault可以阻止它的默认行为而执行其他事件。 再来说说return false,它会阻止所有事件。 换句话来说 function(){ return false; } // IS EQUAL TO function(e) { e.preventDefault(); e.stopPropagation(); } 查看demo

继续阅读»

关于meta keywords那些事儿

1203

摘自wiki:The keywords attribute

Search engines began dropping support for metadata provided by the meta element in 1998, and by the early 2000s, most search engines had veered completely away from reliance on meta elements. In July 2002, AltaVista, one of the last major search engines to still offer support, finally stopped considering them.

No consensus exists whether or not the keywords attribute has any effect on ranking at any of the major search engines today. It is speculated that it does, if the keywords used in the meta can also be found in the page copy itself. With respect to Google, thirty-seven leaders in search engine optimization concluded in April 2007 that the relevance of having your keywords in the meta-attribute keywords is little to none and in September 2009 Matt Cutts of Google announced that they are no longer taking keywords into account whatsoever. However, both these articles suggest that Yahoo! still makes use of the keywords meta tag in some of its rankings. Yahoo! itself claims support for the keywords meta tag in conjunction with other factors for improving search rankings. In Oct 2009 Search Engine Round Table announced that “Yahoo Drops The Meta Keywords Tag Also” but informed us that the announcement made by Yahoo’s Senior Director of Search was incorrect. In the corrected statement Yahoo Senior Director of Search states that “…What changed with Yahoo’s ranking algorithms is that while we still index the meta keyword tag, the ranking importance given to meta keyword tags receives the lowest ranking signal in our system…. it will actually have less effect than introducing those same words in the body of the document, or any other section.

继续阅读»

关于JS预解析一道题

1009

var i=10;
function a() {
    alert(i);
    var i = 2;
    alert(i);
};
a();

挺经典的一道题,结果出得让人不得不觉得奇怪,想知道是虾米回事,内部到底是怎么执行的。

继续阅读»

CSS Reddit Alien

1008

CSS很有趣。今天我用纯CSS和文本做一个Reddit alien 的 logo。它实际是一个链接,当你鼠标划上去时,会有所改变。我不是第一个用这种方式画图的人,Roman Cortes画的CSS Homer是最好的CSS ASCII 艺术例子之一。

用文本和CSS画图的好处是它是可扩展的。如果你在你的浏览器改变字的大小,alien也随着变大变小。因为文字是矢量图形——这意味着CSS ASCII艺术是矢量艺术的一种格式。这也意味着不管你画多大,文件的大小一直都是不变的。如果你需要放一个大的Reddit alien在你的网站,图片的话大于8kb。你将更会(从文件大小方面考虑)选择用CSS版本。

OO_()()OOOO/-oOOOOOOOO()()

继续阅读»

[每日一练]面向对象JavaScript继承例子一

0714


	function Person(){
		this.name;
		this.age;
		this.sex;

		this.getName = function(){
			return this.name;
		}

		this.getSex = function(){
			return this.sex;
		}

		this.getAge = function(){
			return this.age;
		}
	}

	function Girl(){
		this.sex = "female";
		this.isSingle = true;
	}

	Girl.prototype = new Person();
	var jessica = new Girl();
	jessica.name = "Jessica";
	jessica.age = "24";

在面向对象的语言中,使用类来创建一个自定义对象。在JavaScript中一切都可以是对象,用什么办法来创建一个自定义对象?

继续阅读»

文章-等不到的爱

0713

《等不到的爱》未知是可怕的,而等待着未知的到来就让人无法释怀,可是“如果不是为那个期待”“如果拥抱没那么精彩”,有怎么会有等待?等待只是为了给寂寞找个借口,给伤心找个理由,或许当等待只能成为等待的时候,我们就能释怀。

继续阅读»

[每日一学]live vs bind

0418

live()与bind()不同的是一次只能绑定一个事件。

这个方法跟传统的bind很像,区别在于用live来绑定事件会给所有当前以及将来在页面上的元素绑定事件(使用委派的方式)。比如说,如果你给页面上所有的li用live绑定了click事件。那么当在以后增加一个li到这个页面时,对于这个新增加的li,其click事件依然可用。而无需重新给这种新增加的元素绑定事件。

要移除用live绑定的事件,请用die方法

继续阅读»

四月份随笔

0407

我来上海8个月,很多人不理解我为什么离开厦门离开外企,即使这段时间同事叫我回去我依然坚持自己的决定,我一直知道自己想要什么,为什么要离开,我不停脚步地一直往前走,有人说我走得洒脱,走得勇敢,只因为我一直朝着目标,朝着梦想前进。好比如在黑暗中有一束光,你不在乎你脚下的路是有多崎岖,有多坎坷。经常我跟我朋友们说:你有自己的职业计划和人生计划吗?如果我在此刻跌倒,我会想把某一段计划提前,这过程只打乱了这一段的步伐,并未改变主干路线。我不想做温水里的青蛙!

继续阅读»

windows media player播放器把div给遮住的问题

0124

通常,我们碰到flash把div给遮住的问题。想到的解决方案都是:

IE:

	<param name="wmode" value="opaque">

Firefox:

	<embed src="/xx.swf" quality="high" wmode="transparent"></embed>

继续阅读»