JS中setTimeout(hideURLbar, 0)函数的意思以及作用

在某些网页中的脚本会出现以下代码

<script type="application/x-javascript">
    addEventListener("load", function() {
        setTimeout(hideURLbar, 0);
    }, false);
</script>

解析以及作用:
chrome等浏览器会有滚动缓存功能,比如你在A页面滚动后跳转到B页面,点击返回键回到A页面,会发现滚动条位置仍然保持,这是个不错的功能,但是可能在某些特殊场景不适用,所以有些网页则会添加执行以上脚本。
以上代码具体意思为:页面加载的时候添加一个定时器,0秒之后执行hideURLbar函数。hideURLbar函数将页面滚动至坐标(0,1)。

参考来源:https://blog.csdn.net/qq_24549805/article/details/54318661

发布了151 篇原创文章 · 获赞 126 · 访问量 37万+
展开阅读全文

求助,网页代码表单信息收集

05-13

本人是个小白,不太懂计算机语言。这段时间在网上下载了网页,把内容替换完成后发现网页中的表格,提交后没有办法保存给我看。请各位帮帮忙。随便是提交的表格发邮件给我还是保存成一个文本都可以,请各位大神不吝赐教。 下面我把代码贴上来: <!DOCTYPE html> <html> <head> <title>Home</title> <link href="css/bootstrap.css" rel='stylesheet' type='text/css' /> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="js/jquery.min.js"></script> <!-- Custom Theme files --> <!---- animated-css ----> <link href="css/animate.css" rel="stylesheet" type="text/css" media="all"> <script src="js/wow.min.js"></script> <script> new WOW().init(); </script> <!---- animated-css ----> <link href="css/style.css" rel='stylesheet' type='text/css' /> <!-- Custom Theme files --> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script> </script> <!----webfonts---> <link href='http://fonts.useso.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'> <!---//webfonts---> </head> <body> <div class="bg4"> <div class="container"> <!----- start-header----> <div id="home" class="header"> <div class="top-header"> <div class="logo"> <a href="index.html"><img src="images/logo4.png" title="dreams" /></a> </div> <!----start-top-nav----> <nav class="top-nav"> <span class="menu"> </span> <ul class="top-nav"> <li><a href="index.html">Home</a></li> <li><a href="service.html">FACILITIES</a></li> <li><a href="port.html">PRODUCTS</a></li> <li><a href="team.html">QUALITY</a></li> <li class="active"><a href="contact.html">Contact</a></li> </ul> <script> $("span.menu").click(function(){ $(".top-nav ul").slideToggle(200); }); </script> </nav> <div class="clearfix"> </div> </div> </div> <div class="contact-banner text-right"> <h2>Contact</h2> </div> <div class="clearfix"></div> </div> </div> <!----- banner ----> <div class="container"> <div class="contact-us"> <div class="contact-us_left"> <div class="contact-us_info"> <h3 class="style">Find Us Here</h3> <div class="map"> <iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d13558.512473829513!2d119.8721792!3d31.8351189!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x35b41486dc8ab423%3A0x2dcc557ef68ab37d!2s29+Lv+Nan+Lu%2C+Xinbei+Qu%2C+Changzhou+Shi%2C+Jiangsu+Sheng%2C+China%2C+213132!5e0!3m2!1sen!2sus!4v1431479369556" width="400" height="300" frameborder="0" style="border:0"></iframe> </div> </div> <div class="company_address"> <h3 class="style">Sales Manager </h3> <h3 class="style">Minghui Guo(Ming)</h3> <p>29Lvnan Rd, Xuejia Town,<br> Changzhou, Jiangsu, China<br> Tel:0086-519-83182318<br> Mob:0086-15261119179<br> FAX:0086-519-83181993<br> Email: Minghui.Guo@outlook.com</p> </div> </div> <div class="contact_right"> <div class="contact-form"> <h3 class="style">Contact Us</h3> <form method="post" action="index.html"> <div> <p>NAME</p> <span><input name="userName" type="text" class="textbox"></span> </div> <div> <p>E-MAIL</p> <span><input name="userEmail" type="text" class="textbox"></span> </div> <div> <p>MOBILE</p> <span><input name="userPhone" type="text" class="textbox"></span> </div> <div> <p>SUBJECT</p> <span><textarea name="userMsg"> </textarea></span> </div> <div> <input type="submit" value="submit us"> </div> </form> </div> </div> <div class="clear"></div> </div> </div> </div> <!---- footer ----> <div class="footer"> <div class="container"> <div class="footer-grids"> <div class="col-md-3 footer-grid ftr-sec"> <h3>Navigation</h3> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Services</a></li> <li><a href="#">Portfolio</a></li> <li><a href="#">Products</a></li> <li><a href="#">Contact</a></li> </ul> </div> <div class="col-md-3 footer-grid ftr-sec wow fadeInRight" data-wow-delay="0.4s"> <h3>Follows</h3> <ul class="social-icons"> <li><a class="twitter" href="#"><span> </span>twitter</a></li> <li><a class="facebook" href="#"><span> </span>Facebook</a></li> <li><a class="googlepluse" href="#"><span> </span>google+</a></li> </ul> </div> <div class="col-md-3 footer-grid ftr-sec ftr wow fadeInRight" data-wow-delay="0.4s"> <h3>Our Location</h3> <ul class="location"> <li><a class="hm" href="#"><span> </span>29Lvnan Rd, Xuejia Town, Changzhou,Jiangsu,China</a></li> <li><a class="phn" href="#"><span> </span>Mob:0086-15261119179</a></li> </ul> </div> <div class="clearfix"> </div> </div> <p class="copy-right wow bounceInRight" data-wow-delay="0.4s"">Copyright © 2015. Changzhou Hangyuan Machinery Co.,Ltd All rights reserved</p> </div> </div> <!---- footer ----> </body> </html> 问答

有什么办法可以让页面变化时加载脚本文件

12-18

各位大佬,现在遇到这样的一个问题,有一个脚本文件,页面加载完毕后脚本就可以起作用,但是用ajax写预加载(重写html)的时候,脚本文件就不起作用了,请问有什么办法可以让页面变化时加载脚本文件吗??? ![图片说明](https://img-ask.csdn.net/upload/201812/18/1545091465_32276.png) var counter = 1; // 每页展示4个 var num = 6; var pageStart = 0, pageEnd = 0; // dropload $('.Quotation').dropload({ scrollArea: window, domUp: { domClass: 'dropload-up', domRefresh: '<div class="dropload-refresh">↓下拉刷新</div>', domUpdate: '<div class="dropload-update">↑释放更新</div>', domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>' }, domDown: { domClass: 'dropload-down', domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>', domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>', domNoData: '<div class="dropload-noData">已经到达底部</div>' }, loadUpFn: function (me) { me.lock(); // 无数据 me.noData(); me.resetload(); }, loadDownFn: function (me) { var result = ''; counter++; pageEnd =<%=pageCount %> +1;//总页数 pageStart = counter; if (pageStart <= pageEnd) { //alert(pageStart); // alert(pageEnd); $.ajax({ type: 'GET', url: '/Quotation/ArticleWeList1.ashx', dataType: 'json', data: { action: "ArticleWeList", cid: "<%=CId %>", searchName: "<%=SearchName %>", menuid: "<%=MID %>", page: counter }, success: function (data) { // alert(i) for (var i = 0; i < data.length; i++) { result += '<div class="wow fadeInUp" data-wow-delay="0.3s">' + '<span id="ctl00_ContentPlaceHolder_Body_rptNewsList_ctl00_lbWeListMain" class="WeListMain">' + '<span class="WeList_p btns" data-clipboard-action="copy" data-clipboard-target="#foo_'+ data[i].ArticleId + '" ' + data[i].Color + '>' + data[i].Title + '' + ' <input id="foo_'+data[i].ArticleId+'" class="copy-id" type="text" value="' + data[i].Title + '">' + '</span>' + '<ul data-am-widget="gallery" class="We_Title_Kuang am-gallery am-avg-sm-2 am-avg-md-3 am-avg-lg-4 am-gallery-overlay" data-am-gallery="{ pureview: true }">' + '<div class="">' + '' + data[i].ArticleImg + '' + '</div>' + '</ul>' + '<span id="" class="DateTime">' + data[i].UpdateTime + '' + '</span>' + '</span>' + '</div>'; if ((i + 1) > data.length) { //alert(i + 1) // 锁定 me.lock(); // 无数据 me.noData(); break; } } // 为了测试,延迟1秒加载 setTimeout(function () { $('.P_Exhibition').append(result); // 每次数据加载完,必须重置 me.resetload(); }, 1000); }, error: function (xhr, type) { alert('Ajax error!'); // 即使加载出错,也得重置 me.resetload(); } }); } else { //alert(pageStart); // 锁定 me.lock(); // 无数据 me.noData(); me.resetload(); } }, threshold: 50 }); }); </script> <script src="/Upload/WeCha/js/amazeui.js"></script> ``` ``` 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 程序猿惹谁了 设计师: 上身试试

分享到微信朋友圈

×

扫一扫,手机浏览