HTML5中怎么使用地理位置实现定位功能

本篇内容介绍了“HTML5中怎么使用地理位置实现定位功能”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的玛纳斯网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

我们可以通过navigator.geolocation获取地理位置对象,他提供了下列方法:

getCurrentPosition(回调,errorCallback,选项):获取当前位置;

watchPosition(回调,错误的选项):开始监控当前位置;

clearWatch(ID):停止监控当前位置

注:下面例子使用的浏览器是铬,使用其他浏览器我不能保证运行结果和例子显示的结果一致

1.当前电子杂志位置

我们将使用getCurrentPosition方法获取当前位置,位置信息不会以结果的形式直接返回,我们需要使用回调函数进行处理。

复制代码代码如下: 

<!DOCTYPE HTML>

示例</ title></p><p><style></p><p>表{border-colla ps e:塌陷;}</p><p>th,td {padding:4px;}</p><p>th {text-align:right; }</p><p></ style></p><p></ head></p><p><body></p><p><table border =“ 1”></p><p><tr></p><p><th>经度:</ th></p><p><td id =“ longitude”>-</ td></p><p><th>纬度: </ th></p><p><td id =“ latitude”>-</ td></p><p></ tr></p><p><tr></p><p><th>海拔高度:</ th></p><p><td id =“ altitude”>-</ td></p><p><th>准确性:</ th></p><p><td id =“精度“>-</ td></p><p></ tr></p><p><tr></p><p><th>海拔精度:</ th></p><p><td id =” altitudeAccuracy“>-</ td></p><p><th>标题:</ th></p><p><td id =“ heading”>-</ td></p><p></ tr></p><p><tr></p><p><th>速度:</ th></p><p><td id =“ speed”>-</ td></p><p><th>时间戳:</ th></p><p><td id =“ timestamp”>-</ td></p><p></ tr></p><p></ table></p><p><script></p><p>navigator.geolocation.getCurrentPosition(displayPosition);</p><p>函数displayPosition(pos){</p><p>var pr operties = ['经度','纬度','高度','精度','altitudeAccuracy','航向','速度']];</p><p>for(var i = 0,len = properties.length; i <len; i ++){</p><p>var value = pos.coords [properties [i]];</p><p>document.getElementById(properties [i])。innerHTML =值;</p><p>}</p><p>document.getElementById('timestamp')。innerHTML = pos.timestamp;</p><p>}</p><p></ script></p><p></ body></p><p></ html></p><p>返回的位置对象包含两个属性,坐标:返回坐标信息;时间戳:获取坐标信息的时间。其中坐标又包括以下属性:纬度:纬度;经度:经度;海拔:高度;精度:精确度(米); heightAccuracy:高度精确度(米);航向:行进方向;速度:行进速度(米/秒)。</p><p>并不是所有的信息都会返回,这必须您携带浏览器的设备。像有GPS,加速器,罗盘的移动设备会返回大部分信息,家用电脑就不行了。</p><p>点击允许,获取坐标信息。</p><p>2.处理异常</p><p>现在我们介绍了getCurrentPosition的异常处理,他是通过使用errorCallback进行函数实现的。函数返回的参数error包含两个属性,代码:错误类型的代码;消息:错误信息。code包含三个值: 1:用户没有授权使用地理位置; 2:无法获取坐标信息; 3:获取信息超时。</p><p>下面我们看个例子:</p><p>复制代码代码如下: </p><p><!DOCTYPE HTML></p><p><html></p><p><head></p><p><title>示例</ title></p><p><style></p><p>表{边界折叠:折叠;}</p><p>th,td {填充:4px;}</p><p>{文本对齐:右;}</p><p>< / style></p><p></ head></p><p><body></p><p><table border =“ 1”></p><p><tr></p><p><th>经度:</ th></p><p><td id =“ longitude”>-</ td></p><p><th>纬度:</ th></p><p><td id =“ latitude”>-</ td></p><p></ tr></p><p><tr></p><p><th>海拔高度:</ th></p><p><td id =“ altitude”>-</ td></p><p><th>准确性:< / th></p><p><td id =“ accuracy”>-</ td></p><p></ tr></p><p><tr></p><p><th>高度精度:</ th></p><p><td id =“ altitudeAccuracy”>-</ td></p><p><th>标题:</ th></p><p><td id =“ heading”>-</ td></p><p></ tr></p><p><tr></p><p><th>速度:</ th></p><p><td id =“ speed”>-</ td></p><p><th>时间戳:</ th></p><p><td id =“ timestamp”>-</ td></p><p></ tr></p><p><tr></p><p><th>错误代码:</ th></p><p><td id =“ errcode”>-</ td></p><p><th>错误消息:</ th></p><p><td id =“ errmessage”>-</ td></p><p></ tr></p><p></ table></p><p><script></p><p>navigator.geolocation.getCurrentPosition(displayPosition,handleError);</p><p>函数displayPosition(pos){</p><p>var properties = [“经度”,“纬度”,“海拔”,“</p><p>document.getElementById(properties [i])。innerHTML =值;</p><p>}</p><p>document.getElementById(“ timestamp”)。innerHTML = pos.timestamp;</p><p>}</p><p>函数handleError(err){</p><p>document.getElementById(“ errcode”)。innerHTML = err.code;</p><p>document.getElementById(“ errmessage”)。innerHTML = err.message;</p><p>}</p><p></ script></p><p></ body></p><p></ html></p><p>拒绝授权,运行结果:</p><p>3.使用</p><p>geoolocation可选参数项getCurrentPosition(callback,errorCallback,options)中的选项有如下参数可以使用,启用高精度:使用最好的效果;超时时间:超时时间(毫秒);最大年龄:指定缓存时间(毫秒)。我们来下下面的例子:</p><p>复制代码代码如下: </p><p><!DOCTYPE HTML></p><p><html></p><p><head></p><p><title>示例</ title></p><p><style></p><p>表{边界折叠:折叠;}</p><p>th,td {填充:4px;}</p><p>{文本对齐:右;}</p><p>< / style></p><p></ head></p><p><body></p><p><table border =“ 1”></p><p><tr></p><p><th>经度:</ th></p><p><td id =“ longitude”>-</ td></p><p><th>纬度:</ th></p><p><td id =“ latitude”>-</ td></p><p></ tr></p><p><tr></p><p><th>海拔高度:</ th></p><p><td id =“ altitude”>-</ td></p><p><th>准确性:< / th></p><p><td id =“ accuracy”>-</ td></p><p></ tr></p><p><tr></p><p><th>高度精度:</ th></p><p><td id =“ altitudeAccuracy”>-</ td></p><p><th>标题:</ th></p><p><td id =“ heading”>-</ td></p><p></ tr></p><p><tr></p><p><th>速度:</ th></p><p><td id =“ speed”>-</ td></p><p><th>时间戳:</ th></p><p><td id =“ timestamp”>-</ td></p><p></ tr></p><p><tr></p><p><th>错误代码:</ th></p><p><td id =“ errcode”>-</ td></p><p><th>错误消息:</ th></p><p><td id =“ errmessage”>-</ td></p><p></ tr></p><p></ table></p><p><script></p><p>var options = {</p><p>enableHighAccuracy:false,</p><p>timeout:2000,</p><p>maximumAge:30000</p><p>};</p><p>navigator.geolocation.getCurrentPosition(displayPosition,handleError,options);</p><p>var属性= [“经度”,“纬度”,“高度”,“精度”,“ altitudeAccuracy”,“航向”,“速度”];</p><p>for(var i = 0; i <properties.length; i ++){</p><p>var value = pos.coords [properties [i]];</p><p>document.getElementById(properties [i])。innerHTML =值;</p><p>}</p><p>document.getElementById(“ timestamp”)。innerHTML = pos.timestamp;</p><p>}</p><p>函数handleError(err){</p><p>document.getElementById(“ errcode”)。innerHTML = err.code;</p><p>document.getElementById(“ errmessage”)。innerHTML = err.message;</p><p>}</p><p></ script></p><p></ body></p><p></ html></p><p>4.监视位置变化</p><p>下面我们介绍使用watchPosition方法实现位置变化的监视,他的使用方法和getCurrentPosition一样。</p><p>复制代码代码如下: </p><p><!DOCTYPE HTML></p><p><html></p><p><head></p><p><title>示例</ title></p><p><style></p><p>表{边界折叠:折叠;}</p><p>th,td {填充:4px;}</p><p>{文本对齐:右;}</p><p>< / style></p><p></ head></p><p><body></p><p><table border =“ 1”></p><p><tr></p><p><th>经度:</ th></p><p><td id =“ longitude”>-</ td></p><p><th>纬度:</ th></p><p><td id =“ latitude”>-</ td></p><p></ tr></p><p><tr></p><p><th>海拔高度:</ th></p><p><td id =“ altitude”>-</ td></p><p><th>准确性:< / th></p><p><td id =“ accuracy”>-</ td></p><p></ tr></p><p><tr></p><p><th>高度精度:</ th></p><p><td id =“ altitudeAccuracy”>-</ td></p><p><th>标题:</ th></p><p>var watchID = navigator.geolocation.watchPosition(displayPosition,handleError,options); document.getElementById(“ pressme”)。onclick =函数(e){</p><p>navigator.geolocation.clearWatch(watchID);</p><p>};</p><p>函数displayPosition(pos){</p><p>var properties = [“经度”,“纬度”,“海拔”,“精度”,“ altitudeAccuracy”,“航向”,“速度”];</p><p>for(var i = 0; i <properties.length; i ++){</p><p>var value = pos.coords [properties [i]];</p><p>document.getElementById(properties [i])。innerHTML =值;</p><p>}</p><p>document.getElementById(“ timestamp”)。innerHTML = pos.timestamp;</p><p>}</p><p>函数handleError(err){</p><p>document.getElementById(“ errcode”)。innerHTML = err.code;</p><p>document.getElementById(“ errmessage”)。innerHTML = err.message;</p><p>}</p><p></ script></p><p></ body></p><p>当点击Cancel Watch按钮时,停止监视。demo</p><p>“HTML5中怎么使用地理位置实现定位功能”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!</p> <br> 分享题目:HTML5中怎么使用地理位置实现定位功能 <br> 本文路径:<a href="http://zjjierui.cn/article/pojhpg.html">http://zjjierui.cn/article/pojhpg.html</a> </div> </div> <div class="other"> <h3>其他资讯</h3> <ul> <li> <a href="/article/deipedd.html">阿里云服务器苏州总代理 阿里云服务器售后服务Tel </a> </li><li> <a href="/article/deipehg.html">路由器那种比较好 路由器那种好百度知道</a> </li><li> <a href="/article/deipepc.html">linux升级gcc命令 linux升级glibc真正成功的</a> </li><li> <a href="/article/deipesp.html">远程桌面进入阿里云服务器 远程登录阿里云服务器</a> </li><li> <a href="/article/deipehh.html">核心路由器信号 核心路由器作用</a> </li> </ul> </div> </div> <div class="f_service_con"> <div class="h_fumin"> <div class="h_fumin_lei"> <div class="h_fumin_lei_tu"><img src="/Public/Home/images/f_service01.png"></div> <p>售后响应及时</p><span>7×24小时客服热线</span> </div> <div class="h_fumin_lei"> <div class="h_fumin_lei_tu"><img src="/Public/Home/images/f_service02.png"></div> <p>数据备份</p><span>更安全、更高效、更稳定</span> </div> <div class="h_fumin_lei"> <div class="h_fumin_lei_tu"><img src="/Public/Home/images/f_service03.png"></div> <p>价格公道精准</p><span>项目经理精准报价不弄虚作假</span> </div> <div class="h_fumin_lei"> <div class="h_fumin_lei_tu"><img src="/Public/Home/images/f_service04.png"></div> <p>合作无风险</p><span>重合同讲信誉,无效全额退款</span> </div> </div> </div> <div class="footerbar"> <div class="footer-t"> <div class="f-box"> <div class="f-1"> <div class="f-t"> <h2>联系我们</h2> <span>TEL</span> </div> <div class="f-b"> <h1><a href="tel:13518219792" rel="nofollow">135-1821-9792</a></h1> <h1><a href="tel:028-86922220" rel="nofollow">028-86922220</a></h1> <p>地址:成都市太升南路288号锦天国际</p> </div> </div> <div class="f-2"> <div class="f-t"> <h2>快捷导航</h2> <span>Shortcut</span> </div> <div class="f-b"> <ul > </ul> <ul > <li><a href="/jianshe" title="广元网站建设">广元网站建设</a></li> <li><a href="/jianshe#ym_websiteBox2" title="品牌网站建设">品牌网站建设</a></li> <li><a href="/jianshe#ym_websiteBox1" title="企业网站建设">企业网站建设</a></li> <li><a href="/jianshe#ym_websiteBox4" title="集团网站建设">集团网站建设</a></li> <li><a href="/jianshe#ym_websiteBox4_2" title="外贸网站建设">外贸网站建设</a></li> <li><a href="/jianshe#ym_websiteBox4_5" title="企业宣传视频">企业宣传视频</a></li> </ul> <ul > <li><a href="/weixin" title="微信开发">微信开发</a></li> <li><a href="/weixin#item1" title="公众号开发">公众号开发</a></li> <li><a href="/weixin#item2" title="微商城建设">微商城建设</a></li> <li><a href="/weixin#item3" title="微官网建设">微官网建设</a></li> <li><a href="/weixin#item4" title="小程序开发">小程序开发</a></li> </ul> <ul> <li><a href="/case/" title="网站作品案例">网站作品案例</a></li> <li><a href="/case/" title="品牌网站案例">品牌网站案例</a></li> <li><a href="/case/" title="集团网站案例">集团网站案例</a></li> <li><a href="/case/" title="企业网站案例">企业网站案例</a></li> <li><a href="/case/" title="外贸网站案例">外贸网站案例</a></li> <li><a href="/case/" title="营销网站案例">营销网站案例</a></li> </ul> <ul style="margin:0;"> <li><a href="/about/">广元建站</a></li> <li><a href="/about/">公司简介</a></li> <li><a href="/about#ab_item3">企业文化</a></li> <li><a href="/contact">联系我们</a></li> <li><a href="/Pay.html">付款方式</a></li> <li><a href="/jianshe#ym_websiteBox8">售后服务</a></li> </ul> <div style="clear:both;"></div> </div> </div> <div class="f-3"> <div class="f-t"> <h2>二维码</h2> <span>QR CODE</span> </div> <div class="f-b"> <ul> <li><img src="/Public/Home/images/fewm.png"> <p>微信公众号</p> </li> <li style="margin: 0"><img src="/Public/Home/images/fewm2.png"> <p>手机端网站</p> </li> <div style="clear:both;"></div> </ul> </div> </div> <div style="clear:both;"></div> </div> </div> <div class="footer-about"> <div class="w1200">广元优众联杰建站公司是一家专注从事于高品质视觉体验及互联网设计开发,<a href="/" target="_blank">广元网站建设</a>,<a href="/jianshe" target="_blank">广元网站设计</a>,<a href="/jianshe" target="_blank">广元网页设计</a>,<a href="/jianshe" target="_blank">广元网站制作</a>,<a href="/jianshe#ym_websiteBox2" target="_blank">品牌网站建设</a>,<a href="/jianshe#ym_websiteBox3" target="_blank">营销网站建设</a>,<a href="/jianshe#ym_websiteBox4" target="_blank">集团网站建设</a>,<a href="/jianshe#ym_websiteBox1" target="_blank">企业网站建设</a>,<a href="/jianshe#ym_websiteBox4_2" target="_blank">外贸网站建设</a>,<a href="/jianshe#ym_websiteBox4_3" target="_blank">响应式网站建设</a>,<a href="/weixin#item4" target="_blank">小程序开发</a>,<a href="/weixin" target="_blank">微信开发</a>,<a href="/jianshe#ym_websiteBox4_4" target="_blank">企业形象设计</a>,<a href="/jianshe#ym_websiteBox4_5" target="_blank">企业宣传视频</a>等服务,优众联杰建站位于广元市龙岗区大运软件小镇,优众联杰建站拥有经验丰富的高级网站建设工程师和一流的网页高端设计人员,具备各种规模与类型网站建设的雄厚实力,在网站建设领域树立了自己独特的设计风格。 </div> <div class="friend-links"> <h6 class="clearfix"> <span class="tilte">友情链接</span> <a class="exchagne" href="http://wpa.qq.com/msgrd?v=3&uin=631063699&site=qq&menu=yes">交换友情链接</a> </h6> <div class="link-list clearfix"> <div class="link-slider"> <a href="http://www.wcggcd.com/" title="成都广告制作" target="_blank">成都广告制作</a>   <a href="http://www.gzruizhi.cn/" title="宜宾冠赛网站" target="_blank">宜宾冠赛网站</a>   <a href="http://www.cdkjz.cn/small/" title="成都小程序开发" target="_blank">成都小程序开发</a>   <a href="https://www.cdxwcx.com/wangzhan/dingzhi.html" title="定制网站" target="_blank">定制网站</a>   <a href="https://www.cdxwcx.com/wangzhan/case/dfjg.html" title="东电技服" target="_blank">东电技服</a>   <a href="https://www.cdcxhl.com/city/chengdu.html" title="四川成都网站建设" target="_blank">四川成都网站建设</a>   <a href="https://www.cdcxhl.com/tuoguan/yaan/" title="雅安服务器托管" target="_blank">雅安服务器托管</a>   <a href="http://m.cdcxhl.cn/qiye/ " title="企业网站建设" target="_blank">企业网站建设</a>   <a href="http://m.cdcxhl.com/liucheng.html" title="成都网站建设流程" target="_blank">成都网站建设流程</a>   <a href="https://www.cdcxhl.cn/ " title="香港空间" target="_blank">香港空间</a>    </div> </div> </div> </div> <div class="footer-b"> <div class="f-box"> <ul> <li><a href="/jianshe#ym_websiteBox6" target="_blank">服务流程</a></li> <li><a href="/jianshe#ym_websiteBox8" target="_blank">售后服务</a></li> <li><a href="/about/" target="_blank">联系我们</a></li> <li><a href="https://www.cdxwcx.com/pay/" target="_blank">付款方式</a></li> <li><a href="https://www.cdcxhl.com/menu.html" target="_blank">网站地图</a></li> <li><a href="#" target="_blank">sitemap</a></li> <li> <p> <script data-cfasync="false" src="/Public/Home/js/email-decode.min.js"></script> </p> </li> <div style="clear:both;"></div> </ul> <p class="copy">Copyright © 2025 成都优众联杰科技有限公司 广元建站公司 All Rights Reserved   <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备2024116266号-5</a> <a style="display:none" target="_blank" href="###"><img style="vertical-align:middle" border="0" src="" width="65" height="25" /></a> </p> <div style="clear:both;"></div> </div> </div> <div class="sj_footer"> <div class="f-box"> <ul> <li><a href="/jianshe" target="_blank">网站建设</a></li> <li><a href="/jianshe#ym_websiteBox6" target="_blank">服务流程</a></li> <li><a href="/jianshe#ym_websiteBox8" target="_blank">售后服务</a></li> <li><a href="https://www.cdxwcx.com/pay/" target="_blank">付款方式</a></li> <li><a href="/about/" target="_blank">关于我们</a></li> <li><a href="https://www.cdcxhl.com/menu.html" target="_blank">网站地图</a></li> <div style="clear:both;"></div> </ul> <p class="copy">Copyright © 2025 成都优众联杰科技有限公司 广元建站公司 </p> <p class="copy"> <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备2024116266号-5</a>  <a href="###" target="_blank"><img src="/Public/Home/images/govicon.gif" width="20" height="28" border="0" style="border-width:0px;border:hidden; border:none;"></a></p> <div style="clear:both;"></div> </div> </div> </div> <script type='text/javascript' src='/Public/Home/js/qqkefu.js'></script> <div class="qqkefu"> <ul> <li class="qq_czaa" id="130"><b class="a"></b>135-1821-9792</li> <li class="qq_czaa" id="130"><a href="tencent://message/?uin=1683211881"><b class="b"></b>业务咨询QQ</a></li> <li class="qq_czaa" id="130"><a href="javascript:showDiv()"><b class="f"></b>提交合作意向表</a></li> <li class="qq_czb"> <b class="c"></b> <div class="erweima"> <p><img src="/Public/Home/images/right_erweima.png"></p> </div> </li> <li class="top"><span></span></li> </ul> </div> <div id="popDiv" class="mydiv" style="display:none;"> <a class="mydiv_clk" href="javascript:closeDiv()">X</a> <div class="mydiv_list"> <div class="c_f_title"><span class="c_f_t">合作意向表</span></div> <div class="c_f_con"> <form id="form1" name="form1" class="mess_form" method="post" action="/post_order"> <input name='enews' type='hidden' value='AddFeedback'> <input name="bid" value="1" type="hidden"> <input type="hidden" name="ecmsfrom" value="9"> <input type="hidden" name='title' value="客户提交需求"> <li class="c_n"><span>公司名称</span> <dl><input name='gsname' id='gsname' type="text"></dl> </li> <li class="c_n"><span>邮箱</span> <dl><input name='gemail' id='gemail' type="text"></dl> </li> <li class="c_n xmm"> <div class="xmm_01"><span>姓名</span> <dl class="c_n_i"><input name='name' id='name' type="text"></dl> </div> <div class="xmm_01"><span style="text-align:center">电话</span> <dl class="c_n_i"><input name="tel" type="text"></dl> </div> </li> <li class="c_tser">您需要的服务</li> <li class="clearfix"> <dd><label><input type="radio" name='hobby' id='hobby' value="高端网站建设"><span>高端网站建设</span></label></dd> <dd><label><input type="radio" name='hobby' id='hobby' value="我需要做微信营销"><span>我需要做微信营销</span></label></dd> <dd><label><input type="radio" name='hobby' id='hobby' value="要找长期合作,需要年度服务"><span>要找长期合作,需要年度服务</span></label></dd> <dd><label><input type="radio" name='hobby' id='hobby' value="我需要做购物商城"><span>我需要做购物商城</span></label></dd> <dd><label><input type="radio" name='hobby' id='hobby' value="我需要网站改版"><span>我需要网站改版</span></label></dd> <dd><label><input type="radio" name='hobby' id='hobby' value="其他"><span>其他</span></label></dd> </li> <li class="c_tser">您关注的地方</li> <li class="clearfix"> <dd><label><input type="radio" name='hobby2' id='hobby2' value="对功能要求比较高"><span>对功能要求比较高</span></label></dd> <dd><label><input type="radio" name='hobby2' id='hobby2' value="对设计创意要求比较高"><span>对设计创意要求比较高</span></label></dd> <dd><label><input type="radio" name='hobby2' id='hobby2' value="需要可以购物支付"><span>需要可以购物支付</span></label></dd> <dd><label><input type="radio" name='hobby2' id='hobby2' value="搜索引擎排名"><span>搜索引擎排名</span></label></dd> </li> <li class="c_tser">预算</li> <li class="clearfix clearfix2"> <dd><label><input type="radio" name='hobby3' id='hobby3' value="一万以内"><span>一万以内</span></label> </dd> <dd><label><input type="radio" name='hobby3' id='hobby3' value="1-3万"><span>1-3万</span></label> </dd> <dd><label><input type="radio" name='hobby3' id='hobby3' value="3-5万"><span>3-5万</span></label> </dd> <dd><label><input type="radio" name='hobby3' id='hobby3' value="5万以上"><span>5万以上</span></label> </dd> <dd><label><input type="radio" name='hobby3' id='hobby3' value="需招投标"><span>需招投标</span></label> </dd> </li> <li class="c_n" style="border-top:1px solid #eee; padding-top:10px"><span>验证码</span> <dl class="c_n_i yzmm"><input type="text" name='code' id='code' value=""></dl><span style="text-align:center"><img src="/Public/Home/images/1661eb19783442c38063791555cd0d80.gif" onclick="this.src=this.src + '?'" width="100" height="40"></span> </li> <li class="clearfix"> <dd class="submit"><input name='submit' type="submit" value="提交需求"></dd> </li> </form> </div> </div> </div> <div id="bg" class="bg" style="display:none;"></div> <div id='popIframe' class='popIframe' frameborder='0'></div> <script> //提交需求选项 $(document).ready(function (e) { $(".mess_form").submit(function () { if ($("#gsname").val() == "") { alert("请填写您的公司名称!"); $("#gsname").focus(); return false; } if ($("#gemail").val() == "") { alert("请填写您的邮箱"); $("#gemail").focus(); return false; } if ($("#name").val() == "") { alert("请填写您的姓名!"); $("#name").focus(); return false; } if ($("#tel").val() == "") { alert("请填写您的电话!"); $("#tel").focus(); return false; } if ($("#hobby").val() == "") { alert("请选择您需要的服务!"); $("#hobby").focus(); return false; } if ($("#hobby2").val() == "") { alert("请选择您关注的地方!"); $("#hobby2").focus(); return false; } if ($("#hobby3").val() == "") { alert("请选择您的预算!"); $("#hobby3").focus(); return false; } if ($("#code").val() == "") { alert("请填写正确的验证码!"); $("#code").focus(); return false; } }); }); </script> <script language="javascript" type="text/javascript"> //提交需求窗口 function showDiv() { document.getElementById('popDiv').style.display = 'block'; document.getElementById('popIframe').style.display = 'block'; document.getElementById('bg').style.display = 'block'; } function closeDiv() { document.getElementById('popDiv').style.display = 'none'; document.getElementById('bg').style.display = 'none'; document.getElementById('popIframe').style.display = 'none'; } </script> <script type="text/javascript" src="/Public/Home/js/scrolltopcontrol.js"></script> <script type="text/javascript" src="/Public/Home/js/su_new.js"></script> </body> </html> <script> $(".con img").each(function(){ var src = $(this).attr("src"); //获取图片地址 var str=new RegExp("http"); var result=str.test(src); if(result==false){ var url = "https://www.cdcxhl.com"+src; //绝对路径 $(this).attr("src",url); } }); window.onload=function(){ document.oncontextmenu=function(){ return false; } } </script>