jQuery Mobile和HTML5开发App推广注册页


Posted in Javascript onNovember 07, 2016

jQuery Mobile和HTML5的组合可以直接开发web版的app,所以用到我当前app中的推广注册页的编写是很恰当的,其实只要你熟悉html4+jquery的组合开发,那么html5+jqueryMobile你会立刻上手。

html5比html4多了很多的标签,特别是多媒体这块有了很好的支持,但是如果只是做一般的web手机页面,那么多数标签是用不上的,JqueryMobile与jquery的不同点就在一些事件名称上,当然这里封装的也是html5的原生事件,还要说一个关于html5提倡的一个规则,这里jquerymobile是遵循了这个规则的, html5里面给标签增加几个新的权限特征, data-role="page"、  data-role="header" 、data-role="content"、 data-role="footer",  为什么html5会增加这几个特征,我觉得多是为支持web版手机app开发而出的,因为html5提倡开发web版app只创建一个html页,然后每个段落=一个新页面,下面我贴一段几个div标签组合成的一个整体页面,当然它们都各自加了上面的特性。

<!--data-role="page"表示这个是一个html5单独页面,可以从另外一个加了page特性的div打开它 -->
<div data-role="page" id="phoneRegister">
<!--data-role="header"这个特性你想成APP的navigationbar -->
<div data-role="header" id="heardId"></div>
<!--data-role="content"内容里面展示页面内容的,必入你放一张表在这个标签里面展示 -->
<div data-role="content"> </div>
<!--data-role="footer"这个特性你想成APP的tabbar -->
<div data-role="footer"> </div>
</div>

上面的div其实就组合成了一个html5页面了。

一、页面注意事项

     1. 首先html5标准页面申明,页面中的第一行代码与html4不一样,

     html5:<!DOCTYPE>

     html4:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

      此标签的作用是告诉浏览器支持什么html规范。

     2.引入jquery和jquerymobile的支持库

      <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />

     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">

      <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

     <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>

      上面的库都是直接通过链接地址引入的,等会我直接贴代码,如果想看效果,可以直接copy代码到一个html页面直接打开就可以运行。

二、整页代码

<!DOCTYPE>
<html>
<head>
 <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
 <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
 <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<title>Insert title here</title>
<script type="text/javascript">
$(document).on("pagecreate", function () {
  var contentHeight = document.body.clientHeight;
  var header = contentHeight * 0.1;
  var content = contentHeight * 0.75;
  var footer = contentHeight * 0.15;
  $("#phoneRegister #heardId").css({ 'height': header + 'px', 'background': '#4dbb49', 'line-height': header + 'px' });
  $("#phoneRegister #contentId").css({ 'height': content + 'px' });
  $("#phoneRegister #footerId").css({ 'height': footer + 'px', ' font-size': '70px', 'line-height': footer + 'px' });
  var flag = false;
  setInterval(function () {
    if (flag == false) {
      $("#presentGiftTitle").css({ 'color': 'rgb(255, 0, 0)' });
      flag = true;
      return;
    }
    if (flag == true) {
      $("#presentGiftTitle").css({ 'color': 'rgb(255, 102, 0)' });
      flag = false;
      return;
    }
  }, 100);
});
//当页面初始化完毕后
$(document).on("pageshow", "#commonRegister", function () { // 当进入页面二时
  var contentHeight = document.body.clientHeight;
  var header = contentHeight * 0.1;
  var content = contentHeight * 0.75;
  var footer = contentHeight * 0.15;
  $("#commonRegister #heardId").css({ 'height': header + 'px', 'background': '#4dbb49', 'line-height': header + 'px' });
  $("#commonRegister #contentId").css({ 'height': content + 'px' });
  $("#commonRegister #footerId").css({ 'height': footer + 'px', 'font-size': '70px', 'line-height': footer + 'px' });
});
$(document).on("pageinit", "#phoneRegister", function () {
  $("#phoneRegisterClick").on("tap", function () {
    var name = $("#phoneRegister #name").val();
    var password = $("#phoneRegister #password").val();
    var re = /^(13[0-9]{9})|(15[89][0-9]{8})$/;
    if (!re.test(name)) {
      alert("请输入正确的手机号!")
      return;
    }
    if (password.length < 6) {
      alert("密码不能小于6位数")
      return;
    }
    var checkBox = $("#phoneRegister #Checkbox1");
    if (!checkBox.is(":checked")) {
      alert("请阅读条例!")
      return;
    }
    //开始发送手机验证
    alertVerifyCodeMethod();
  });
});
$(document).on("pageinit", "#commonRegister", function () {
  $("#commonRegisterClick").on("tap", function () {
    var name = $("#commonRegister #name").val();
    var password = $("#commonRegister #password").val();
    var phonenumber = $("#commonRegister #phoneNumber").val();
    var safemail = $("#commonRegister #safeMail").val();
    var re = /^(13[0-9]{9})|(15[89][0-9]{8})$/;
    var mre = /\w@\w*\.\w/;
    if (name.length < 6) {
      alert("注册用户名不能小于6位数!")
      return;
    }
    if (password.length < 10) {
      alert("密码不能小于10位数")
      return;
    }
    if (!re.test(phonenumber)) {
      alert("请输入正确的手机号!")
      return;
    }
    if (!mre.test(safemail)) {
      alert("请输入正确的邮箱!")
      return;
    }
    var checkBox = $("#commonRegister #Checkbox1");
    if (!checkBox.is(":checked")) {
      alert("请阅读条例!")
      return;
    }
    shareAjaxMethord(0, name, password, phonenumber, safemail);
  });
});
function alertVerifyCodeMethod() {
  if (document.all) {
    document.getElementById("alertVerifyCodeBox").click();
  }
  else {
    var e = document.createEvent("MouseEvents");
    e.initEvent("click", true, true);
    document.getElementById("alertVerifyCodeBox").dispatchEvent(e);
  }
}
function shareAjaxMethord(index, name, password, phone, email) {
  $.ajax({
    type: "POST",
    async: false,
    dataType: "text",
    data: "&sgin=" + index + "&name=" + name + "&password=" + password + "&phone=" + phone + "&email=" + email,
    url: "ajaxMediumPage.ashx",
    success: function (returnDate) {
      if (index == 0) {
        if(returnDate=="1")
        {
          alert("注册成功!");
        }
        else
        {
          alert("注册失败!");
        }
      }
      else if (inedx == 1) {
      }
      else {
      }
    }
  });
}
</script>
</head>
<body>
  <!-- 这个div data-role="page"表明它是一个页面 -->
  <div data-role="page" id="phoneRegister">
    <div data-role="header" id="heardId">
  <div style="margin-left:20px; font-size:17px;  font-weight:bold"><a href="#pagetwo" style="color:white; text-decoration:none;">首页>手机在线注册</a></div>
    </div>
    <div data-role="content" id="contentId">
        <section id="posts">
          <article class="post">
            <header>
              <h4 id="presentGiftTitle">使用手机后注册后立刻赠送100乐币!</h4>
            </header>
            <aside>
              手机号:
              <input id="name" type="text" placeholder="请输入注册帐号!" />
            </aside>
            <aside>
              密  码:
              <input id="password" type="password" placeholder="请输入注册密码!" />
            </aside>
            <aside>
              <div style="margin-left:-15px;">
                <div style="width: 20px;  height: 20px; float:left; margin-top:5px;"> <input id="Checkbox1" style="width: 18px; height: 18px;" type="checkbox" /></div>
                <div style="margin-left:40px;"><h5>打勾注册表示你同意本公司的服务条例!</h5></div>
              </div>
            </aside>
            <aside style="margin-top:20px;">
              <div id="phoneRegisterClick" style="text-align: center; border: 1px solid #666666; background: #4dbb49; color: white; height: 30px; width: 100px; line-height: 30px; ">立即注册<a href="#dialog" id="alertVerifyCodeBox" data-rel="dialog" style="display:none"></a> </div>
            </aside>
            <aside style="margin-top:20px;">
              <div style="float:right"><a href="#commonRegister" data-transition="flip">普通注册(非手机)</a></div>
            </aside>
            <footer></footer>
          </article>
        </section>
    </div>
    <div data-role="footer" id="footerId" style="background:#666666;">
      <div style="width:100%;height:90%;text-align:center;">
        <div style="font-size:13px; height:25%;text-decoration:none;margin-top:0px;padding-top:0px; line-height:16px;">电话:400-900-8000</div>
        <div style="font-size: 13px; height: 25%; text-decoration:none;margin-top: 0px; padding-top: 0px; line-height:16px;">渝ICP备000000-c号</div>
        <div style="font-size: 13px; height: 25%;text-decoration:none; margin-top: 0px; padding-top: 0px; line-height: 16px;">版权所有</div>
      </div>
    </div>
  </div>
<!-- 这个div data-role="page"表明它是一个页面 -->
  <div data-role="page" id="commonRegister">
    <div data-role="header" id="heardId">
      <div style="margin-left:20px; font-size:17px;  font-weight:bold"><a href="#pagetwo" style="color:white; text-decoration:none;">首页>普通用户在线注册</a></div>
    </div>
    <div data-role="content" id="contentId">
        <section id="posts">
          <article class="post">
            <aside>
              帐 号:
              <input id="name" type="text" placeholder="请输入注册帐号!" />
            </aside>
            <aside>
              密  码:
              <input id="password" type="password" placeholder="请输入注册密码!" />
            </aside>
            <aside>
              手机号:
              <input id="phoneNumber" type="text" placeholder="请输入手机号!" />
            </aside>
            <aside>
              安全邮箱:
              <input id="safeMail" type="text" placeholder="请输入安全邮箱!" />
            </aside>
            <aside>
              <div style="margin-left:-15px;">
                <div style="width: 20px;  height: 20px; float:left; margin-top:5px;"> <input id="Checkbox1" style="width: 18px; height: 18px;" type="checkbox" /></div>
                <div style="margin-left:40px;"><h5>打勾注册表示你同意本公司的服务条例!</h5></div>
              </div>
            </aside>
            <aside style="margin-top:20px;">
              <div id="commonRegisterClick" style="text-align:center;border:1px solid #666666; background:#4dbb49;color:white;height:30px;width:100px; line-height:30px;">立即注册 </div>
            </aside>
            <aside style="margin-top:20px;">
              <div style="float:right"><a href="#phoneRegister" data-transition="flip">手机注册(手机号)</a></div>
            </aside>
            <footer></footer>
          </article>
          </section>
    </div>
    <div data-role="footer" id="footerId" style="background:#666666;">
      <div style="width:100%;height:90%;text-align:center;">
        <div style="font-size:13px; height:25%;text-decoration:none;margin-top:0px;padding-top:0px; line-height:16px;">电话:400-900-8000</div>
        <div style="font-size: 13px; height: 25%;text-decoration:none; margin-top: 0px; padding-top: 0px; line-height:16px;">渝ICP备000000-c号</div>
        <div style="font-size: 13px; height: 25%;text-decoration:none; margin-top: 0px; padding-top: 0px; line-height: 16px;">版权所有</div>
      </div>
    </div>
  </div>

  <div data-role="page" id="dialog" style="padding-top:auto">
    <div data-role="header" id="heardId" style="background:#4dbb49">
      <h1>输入验证码</h1>
    </div>
    <div data-role="content" id="contentId">
      <aside>
        验证码:
        <input id="verifyCode" type="text" placeholder="请输入验证码!" />
      </aside>
      <aside>
        <div id="inputVerifyCodeDiv" style="width: 100px; height: 30px; background: #4dbb49; color:white; line-height:30px; float:right; text-align:center">确 定</div>
      </aside>
    </div>
    <div data-role="footer" id="footerId" style="background:#4dbb49">
      <h1></h1>
    </div>
  </div>
</body>
</html>

上面的代码直接copy到一个html页面可以运行。

以上所述是小编给大家介绍的jQuery Mobile和HTML5开发App推广注册页,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!

Javascript 相关文章推荐
新浪刚打开页面出来的全屏广告代码
Apr 02 Javascript
详细分析JavaScript变量类型
Jul 08 Javascript
基于jQuery通过jQuery.form.js插件使用ajax提交form表单
Aug 17 Javascript
JavaScript实现刷新不重记的倒计时
Aug 10 Javascript
js图片上传前预览功能(兼容所有浏览器)
Aug 24 Javascript
AngularJS实现动态切换样式的方法分析
Jun 26 Javascript
vue-cli3脚手架的配置及使用教程
Aug 28 Javascript
Angular6 Filter实现页面搜索的示例代码
Dec 02 Javascript
JavaScript中构造函数与原型链之间的关系详解
Feb 25 Javascript
vue中引入mxGraph的步骤详解
May 17 Javascript
vue中实现Monaco Editor自定义提示功能
Jul 05 Javascript
javascript面向对象三大特征之封装实例详解
Jul 24 Javascript
学习JavaScript图片预加载模块
Nov 07 #Javascript
pc加载更多功能和移动端下拉刷新加载数据
Nov 07 #Javascript
jquery html5 视频播放控制代码
Nov 06 #Javascript
js无提示关闭浏览器窗口的两种方法分析
Nov 06 #Javascript
详解Angular.js的$q.defer()服务异步处理
Nov 06 #Javascript
Bootstrap 3.x打印预览背景色与文字显示异常的解决
Nov 06 #Javascript
d3.js实现简单的网络拓扑图实例代码
Nov 06 #Javascript
You might like
一个好用的分页函数
2006/11/16 PHP
PHP面向接口编程 耦合设计模式 简单范例
2011/03/23 PHP
PHP实现生成带背景的图形验证码功能
2016/10/03 PHP
php实现简单加入购物车功能
2017/03/07 PHP
关于ThinkPhp 框架表单验证及ajax验证问题
2017/07/19 PHP
JS弹出对话框返回值代码(asp.net后台)
2010/12/28 Javascript
jsMind通过鼠标拖拽的方式调整节点位置
2015/04/13 Javascript
Backbone.js的Hello World程序实例
2015/06/19 Javascript
JS常用函数和常用技巧小结
2016/10/15 Javascript
JS无缝滚动效果实现方法分析
2016/12/21 Javascript
js事件委托和事件代理案例分享
2017/07/25 Javascript
jQuery选择器中的特殊符号处理方法
2017/09/08 jQuery
jquery 输入框查找关键字并提亮颜色的实例代码
2018/01/23 jQuery
深入剖析Express cookie-parser中间件实现示例
2018/02/01 Javascript
JavaScript中Object基础内部方法图
2018/02/05 Javascript
JS点击动态添加标签、删除指定标签的代码
2018/04/18 Javascript
Vue项目webpack打包部署到Tomcat刷新报404错误问题的解决方案
2018/05/15 Javascript
JavaScript折半查找(二分查找)算法原理与实现方法示例
2018/08/06 Javascript
bootstrapTable+ajax加载数据 refresh更新数据
2018/08/31 Javascript
vue将后台数据时间戳转换成日期格式
2019/07/31 Javascript
ant-design-vue中的select选择器,对输入值的进行筛选操作
2020/10/24 Javascript
Python实现进程同步和通信的方法
2018/01/02 Python
python实现简单神经网络算法
2018/03/10 Python
Selenium控制浏览器常见操作示例
2018/08/13 Python
详解Django的model查询操作与查询性能优化
2018/10/16 Python
Python设计模式之适配器模式原理与用法详解
2019/01/15 Python
python 进程间数据共享multiProcess.Manger实现解析
2019/09/23 Python
pyinstaller打包单文件时--uac-admin选项不起作用怎么办
2020/04/15 Python
小白教你PyCharm从下载到安装再到科学使用PyCharm2020最新激活码
2020/09/25 Python
HTML5的文档结构和新增标签完全解析
2017/04/21 HTML / CSS
第二层交换机和路由器的区别?第三层交换机和路由器的区别?
2013/05/23 面试题
先进党支部事迹材料
2014/01/13 职场文书
小学教师自我评价
2015/03/04 职场文书
唱歌比赛拉拉队口号
2015/12/25 职场文书
远程教育集中轮训基层干部培训班学习心得体会
2016/01/09 职场文书
教你漂亮打印Pandas DataFrames和Series
2021/05/29 Python