东方骄子


  • 首页

  • 关于

  • 归档

  • 站点地图

  • 公益404

  • 搜索

纯前端markdown编辑器及解析

发表于 2019-01-08 | 分类于 Web前端 |

markdown编辑器

下面是使用freemarker定义的宏,是一个markdown编辑器。

阅读全文 »

js实现上拉加载更多

发表于 2019-01-08 | 分类于 Web前端 |
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
48
49
50
51
52
/**
* 获取滚动条的位置
*
* @returns {number}
*/
function getScrollTop() {
var scrollTop = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
} else if (document.body) {
scrollTop = document.body.scrollTop;
}
return scrollTop;
}

/**
* 获取当前可视范围的高度
*
* @returns {number}
*/
function getClientHeight() {
var clientHeight = 0;
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
} else {
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
}
return clientHeight;
}

/**
* 获取文档完整的高度
*
* @returns {number}
*/
function getScrollHeight() {
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
}

/**
* 是否还有更多内容
*/
var hasMore = true;

/**
* 上拉加载更多事件
*/
window.onscroll = function () {
if (hasMore && getScrollTop() + getClientHeight() === getScrollHeight()) {
console.log("加载更多...");
}
};

当没有更多内容时,把hasMore置为false,否则会一直去尝试加载更多

js返回上一页的实现

发表于 2019-01-08 | 分类于 Web前端 |

如果有上一页则返回上一页,如果没上一页(直接输入url打开的网页)则返回首页。兼容主流浏览器。

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
/**
* 返回
*/
function goBack() {
if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)) {
// IE
if (history.length > 0) {
window.history.go(-1);
} else {
window.location.href = ctx + "/";
}
} else {
// 非IE浏览器
if (navigator.userAgent.indexOf('Firefox') >= 0 ||
navigator.userAgent.indexOf('Opera') >= 0 ||
navigator.userAgent.indexOf('Safari') >= 0 ||
navigator.userAgent.indexOf('Chrome') >= 0 ||
navigator.userAgent.indexOf('WebKit') >= 0) {

if (window.history.length > 1) {
window.history.go(-1);
} else {
window.location.href = ctx + "/";
}
} else {
// 未知的浏览器
window.history.go(-1);
}
}
}

js检测浏览器是PC端还是手机端

发表于 2019-01-08 | 分类于 Web前端 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function IsPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}

//true为PC端,false为手机端
var flag = IsPC();
if (!flag) {
window.location.href = "${ctx}/wap"
}

支付宝扫码支付的开发过程

发表于 2018-10-29 | 分类于 Java后台 |

名词定义

  • 用户:在我们网站上交易的客户。
  • 支付网关:是我们商户和支付宝开放平台对接的系统。
  • 商户系统:充值成功后用于发货的系统。
  • 微信支付平台:是阿里的支付宝开放。

支付宝扫码支付官网地址

支付接口:https://docs.open.alipay.com/api_1/

阅读全文 »
1…456…31
康永敢

康永敢

走路自带音响

151 日志
7 分类
20 标签
RSS
Github
© 2019 康永敢
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4