jquery JavaScript back to top features

Source: Internet
Author: User

Today I got a back to the top JS JQ function

[JavaScript]View Plaincopyprint?
  1. (function ($) {
  2. $.fn.survey=Function (options) {
  3. var defaults={width: "298", Height:"207"};
  4. var options=$.extend (defaults,options);
  5. if ($.browser.msie) {
  6. var ieversion=parseint ($.browser.version)}
  7. Create HTML
  8. var __feedcreat=function () {
  9. var feedhtml=$ (' <div id= ' pubfeedback ' ></div> ');
  10. feedhtml.html (' <a href= ' #top "id=" Backtop "><i></i>\u8fd4\u56de\u9876\u90e8</a><a  href= "#" id= "Callsurvey" ><i></i>\u610f\u89c1\u53cd\u9988</a> ");
  11. $ ("Body"). Append (feedhtml);
  12. __ie6fixed ()
  13. };
  14. Binding events
  15. var __initevent=function () {
  16. $ (window). Resize (function () {
  17. var winw=$ (this). width ();
  18. if (winw<=1124) {$ ("#pubFeedBack"). Hide ()}
  19. else{$ ("#pubFeedBack"). Show ()}
  20. });
  21. $ (window). Bind ("scroll",function () {
  22. if ($ (this). ScrollTop () >50) {
  23. $ ("#backTop"). FadeIn (). css ({"display":"Block"})
  24. }
  25. else{$ ("#backTop"). FadeOut (). css ({"display": ""})}
  26. });
  27. $ ("#backTop"). Bind ("click",function (e) {
  28. E.preventdefault ();
  29. $ ("Html,body"). ScrollTop (0)});
  30. };
  31. Back to Top
  32. var __tip=function (type,tiptext) {
  33. var surveytip=$ ("#D_SurveyTip"), surveymask=$ ("#D_SurveyMask");
  34. if (!surveytip| |! Surveymask) {return}
  35. Surveytip.removeclass ("warning Success"). AddClass (type). HTML (TipText);
  36. Surveymask.css ("display","block");
  37. Surveytip.css ("display","block");
  38. SetTimeout (function () {
  39. SURVEYMASK.CSS ("Display","None");                                                                                                                                                                                                                                                                                                &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;SURVEYTIP.CSS ("Display","none")},1000)
  40. };
  41. IE6 compatible
  42. var __ie6fixed=function () {
  43. if (ieversion!==6) {return}
  44. var surveybox=$ ("#D_SurveyBox");
  45. var pubfeedback=$ ("#pubFeedBack");
  46. if (!surveybox| |! Pubfeedback)
  47. {
  48. return
  49. }
  50. $ (window). Bind ("scroll",function () {
  51. var h=$ (window). Height (), st=$ (window). scrolltop (),_top=h+st-options.height;                                                                                                                                                                  var _top1=h+st-pubfeedback.height () -15;surveybox.css ("Top", _top+"px");
  52. Pubfeedback.css ("Top", _top1+"px")
  53. })
  54. };
  55. Start execution
  56. if (screen.width>=1280)
  57. {
  58. (function () {
  59.     __feedcreat ();                                                                                                                                                 __ Initevent ()                                                                                                                                                                }) ()   
  60. }
  61. }
  62. }) (JQuery);
  63. window.onerror=function () {return false};
  64. if ($.isfunction (document). Survey)) {$ (document). Survey ()}

[CSS]View Plaincopyprint?
  1. #backTop I,#callSurvey i{background:URL (survey.png) no-repeat;}
  2. #pubFeedBack {position:fixed; _position:absolute;right:15px;bottom:15px;width:54px; Font-size:12PX;}   
  3. #backTop,#callSurvey {display:block; Width:52px; padding:1px; Height:56px; Line-height:22px; Text-align:Center; Color:#fff;   Text-decoration:none;}
  4. #backTop {display:none;   Background:#999;}
  5. #backTop: hover{background:#ccc; zoom:1; Text-decoration:none;   Color:#fff;}
  6. #backTop i{display:block; Width:25px; Height:13px; Margin:14px auto 8px;   Background-position:-63px 0;}
  7. #callSurvey {margin-top:1px;   Background:#3687d9;}
  8. #callSurvey: hover{background:#66a4e3; zoom:1; Text-decoration:none;   Color:#fff;}
  9. #callSurvey i{display:block; Width:26px; Height:25px; Margin:9px auto 0;   Background-position:0 0;}
  10. #callSurvey: Hover i{background-position:-30px 0;}

jquery JavaScript back to top features

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.