前端面试(四)

面经 20191129   未完待续...

1. 伪类选择器

first-of-type last-of-type only-of-type only-child

nth-child nth-last-child nth-of-type nth-last-of-type enable disable checked not selection

 

2. 事件委托,使用事件委托有什么好处?

就是让别人来做,这个事件本来是加在某些元素上的,然而你却加到别人身上来做,完成这个事件。

也就是:利用冒泡的原理,把事件加到父级上,触发执行效果。

好处呢:1,提高性能。

 

3.怎么阻止事件冒泡?

阻止事件冒泡:ie:window.event.cancelBubble=true;而非ie:e.stopPropagation();

阻止默认事件:ie:window.event.returnValue = false;return false;而非ie:e.preventDefault();

 

4.跨域的方法:

1> document.domain + iframe (只有在主域相同的时候才能使用该方法)

2> window.name + iframe

3>html5中的postMessage()

4>CORS

5>jsonp

6>websocket

 

跨域支持post请求的:

1>CORS

2>window.postMessage

3>html5的websocket

4>iframe http://www.jianshu.com/p/4773501f1adf

5>flash proxy

 

5.Ajax 请求Json数据该如何解析

1)eval()方法: var dataObj=eval("("+data+")");//转换为json对象

2) 使用Json.parse()

3)new Function()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值