Skip to content

Instantly share code, notes, and snippets.

View zhaoda's full-sized avatar
🏆
Focusing

赵达 zhaoda

🏆
Focusing
View GitHub Profile
@zhaoda
zhaoda / helper.class.php
Last active December 19, 2015 09:29
ZenTaoPMS.4.1版本安装过程和安装后空白问题的解决方案 现象: 安装过程中内容显示缺失,或者安装后页面空白,打开error_reporting后函数array_merge()报错; 原因: php5中array_merge()只接受array类型的参数; 解决: 修改 ~/framework/helper.class.php 第403行,改为 return $files ? $files : array(); //change by zhaoda
<?php
/**
* The helper class file of ZenTaoPHP framework.
*
* The author disclaims copyright to this source code. In place of
* a legal notice, here is a blessing:
*
* May you do good and not evil.
* May you find forgiveness for yourself and forgive others.
* May you share freely, never taking more than you give.
@zhaoda
zhaoda / The front-end development course system.md
Last active December 2, 2019 07:19
前端开发课程体系
@zhaoda
zhaoda / getViewport.js
Last active August 29, 2015 14:04
获取网页大小
// 网页上的每个元素,都有clientHeight和clientWidth属性,
// 这两个属性指元素的内容部分再加上padding的所占据的视觉面积,不包括border和滚动条占用的空间。
// 网页上的每个元素还有scrollHeight和scrollWidth属性,指包含滚动条在内的该元素的视觉面积。
// 大多数情况下,都是document.documentElement.clientWidth返回正确值。
// 但是,在IE6的quirks模式中,document.body.clientWidth返回正确的值,因此函数中加入了对文档模式的判断。
// 方案1
// 必须在页面加载完成后才能运行,否则document对象还没生成,浏览器会报错
// clientWidth和clientHeight都是只读属性,不能对它们赋值
@zhaoda
zhaoda / README.md
Last active August 29, 2015 14:04
获取网页元素的绝对位置

网页元素的绝对位置,指该元素的左上角相对于整张网页左上角的坐标。这个绝对位置要通过计算才能得到。

首先,每个元素都有offsetTop和offsetLeft属性,表示该元素的左上角与父容器(offsetParent对象)左上角的距离。所以,只需要将这两个值进行累加,就可以得到该元素的绝对坐标。

注意:由于在表格和iframe中,offsetParent对象未必等于父容器,所以上面的函数对于表格和iframe中的元素不适用

获取网页元素的绝对位置

@zhaoda
zhaoda / Readme.md
Last active August 29, 2015 14:04
获取网页元素的相对位置

网页元素的相对位置,指该元素左上角相对于浏览器窗口左上角的坐标。

有了绝对位置以后,获得相对位置就很容易了,只要将绝对坐标减去页面的滚动条滚动的距离就可以了。滚动条滚动的垂直距离,是document对象的scrollTop属性;滚动条滚动的水平距离是document对象的scrollLeft属性。

获取网页元素的相对位置

@zhaoda
zhaoda / Cross-Domain-AJAX.md
Last active August 29, 2015 14:04
ajax如何实现跨域请求
  1. 设置document.domain,增加隐藏的iframe做代理页面,只能解决主域相同而二级域名不同的情况,腾讯微博目前使用该方法;
  2. 利用iframelocation.hash,这个办法比较绕并且复杂,并且数据直接暴露在了url中,数据容量和类型都有限等;
  3. 服务器做Proxy代理,需要后端支持;
  4. 通过Script标签,即通常说的JSONP
  5. 使用window.name,name值在不同的页面(甚至不同域名)加载后依旧存在,并且可以支持非常长的 name 值(2MB),具体原理请参考http://www.planabc.net/2008/09/01/window_name_transport/

如果能说出第5个方案,说明很专业,知识面涉猎比较广。

@zhaoda
zhaoda / event-model.md
Last active January 22, 2019 15:01
浏览器事件模型

捕获型事件

当你使用捕获型事件时

               | |
---------------| |-----------------
| element1     | |                |
|   -----------| |-----------     |
|   |element2  \ /          |     |
@zhaoda
zhaoda / Readme.md
Last active August 29, 2015 14:04
css3伸缩盒,考察css3 box-flex 等新布局属性

根据已有html结构,用CSS3完成图1的布局,主要考察对CSS3新属性 display: -webkit-flex flexdisplay: box box-flex 的掌握程度。

如果能写出以上几个属性,并了解这些属性的作用,就算掌握CSS3新布局方式。

参考资料 参考 http://www.inserthtml.com/2012/05/css3-flex-box-specification-change-layout-design/

<!--已知的html结构,不能修改-->
<div id="header"></div>
@zhaoda
zhaoda / es5-array-method.md
Created July 16, 2014 09:00
ES5中增加的Array新方法

至少写出5个ES5中Array增加的新方法,考察对ES5的掌握程度

  1. forEach
  2. map
  3. filter
  4. some
  5. every
  6. indexOf
  7. lastIndexOf
  8. reduce
@zhaoda
zhaoda / es6-new-features.md
Created July 16, 2014 09:15
ES6新特性

考察对ES6的掌握程度,说的越多越好,只要说出下面的一些关键词就行。

  1. 语法糖
  2. 解构
  3. Let和Const
  4. For-Of
  5. 箭头函数 =>
  6. 延伸操作符
  7. 剩余变量
  8. 默认参数