半岛铁盒

生活、技术个人博客


  • 首页

  • 分类

  • 归档

  • 标签

  • 关于

读取cookie

发表于 2017-05-02 | 分类于 问题 | | 阅读次数

读取cookie信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script type="text/javascript" src="js/user.js"></script>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>

<script type="text/javascript">
$(function(){
var U2NickName=$.cookie('U2NickName'); // 读取 cookie
if (U2NickName!=null&&U2NickName!="") {
$("#xingm").html(U2NickName);
$("#login_form").hide();
}else{
$("#xingm").hide();
$("#logoutBtn").hide();
}

bxslider 插件问题

发表于 2017-05-02 | 分类于 学习 jQuery | | 阅读次数

###bxslider在点击pager或上下页之后自动播放

这个是最近在项目中遇到的,bxslider在auto:true的时候会自动发播放,但是当你点击了上下页或者pager的序号之后自动播放就停止了。
经过一番搜索和各种翻查api,终于找出了解决办法,代码如下

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
翻页修改位置:
var clickPagerBind = function(e){
// if auto show is running, stop it
if (slider.settings.auto) el.stopAuto();
var pagerLink = $(e.currentTarget);
if(pagerLink.attr('data-slide-index') !== undefined){
var pagerIndex = parseInt(pagerLink.attr('data-slide-index'));
// if clicked pager link is not active, continue with the goToSlide call
if(pagerIndex != slider.active.index) el.goToSlide(pagerIndex);

el.startAuto();
e.preventDefault();
}
}

左右轮播按钮:
var clickNextBind = function(e){
// if auto show is running, stop it
if (slider.settings.auto) el.stopAuto();
el.goToNextSlide();
el.startAuto();
e.preventDefault();
}

var clickPrevBind = function(e){
// if auto show is running, stop it
if (slider.settings.auto) el.stopAuto();
el.goToPrevSlide();
el.startAuto();
e.preventDefault();
}

这个才是左右按钮的,加上
el.startAuto();
这段代码

判断是否是手机端并跳转

发表于 2017-05-02 | 分类于 学习 | | 阅读次数

判断是否是手机端并跳转
以下代码为常用来判断访问者的访问设备的类型来进行相应的跳转

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script type="text/javascript">
// borwserRedirect
(function browserRedirect(){
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad';
var bIsIphone = sUserAgent.match(/iphone os/i) == 'iphone os';
var bIsMidp = sUserAgent.match(/midp/i) == 'midp';
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4';
var bIsUc = sUserAgent.match(/ucweb/i) == 'web';
var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce';
var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile';
var bIsAndroid = sUserAgent.match(/android/i) == 'android';

if(bIsIpad || bIsIphone || bIsMidp || bIsUc7 || bIsUc || bIsCE || bIsWM || bIsAndroid ){
window.location.href = '跳转的移动端网址';
}
})();
</script>

web禁用点击毫毛调用系统拨号行为

发表于 2017-05-02 | 分类于 学习 | | 阅读次数

开发APP应用时,有时候需要用wap页来实现一些相应的需求,在wap页开发中就可能出现一些问题,比如在iOS、Android下点击一串电话号码会调用系统默认的拨号操作,但是实际上可能并不需要这样,因此需要禁用这些默认行为。

解决方案:在页面中假如元标签

1
2
3
4
<head>  
<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />
</head>
1…131415…18
Jksen zhangxing

Jksen zhangxing

酝酿中....

69 日志
11 分类
33 标签
RSS
GitHub 微博
Links
  • 我的站点
© 2020 Jksen zhangxing
由 Hexo 强力驱动
主题 - NexT.Mist