Today I got a back to the top JS JQ function
[JavaScript]View Plaincopyprint?
- (function ($) {
- $.fn.survey=Function (options) {
- var defaults={width: "298", Height:"207"};
- var options=$.extend (defaults,options);
- if ($.browser.msie) {
- var ieversion=parseint ($.browser.version)}
- Create HTML
- var __feedcreat=function () {
- var feedhtml=$ (' <div id= ' pubfeedback ' ></div> ');
- 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> ");
- $ ("Body"). Append (feedhtml);
- __ie6fixed ()
- };
- Binding events
- var __initevent=function () {
- $ (window). Resize (function () {
- var winw=$ (this). width ();
- if (winw<=1124) {$ ("#pubFeedBack"). Hide ()}
- else{$ ("#pubFeedBack"). Show ()}
- });
- $ (window). Bind ("scroll",function () {
- if ($ (this). ScrollTop () >50) {
- $ ("#backTop"). FadeIn (). css ({"display":"Block"})
- }
- else{$ ("#backTop"). FadeOut (). css ({"display": ""})}
- });
- $ ("#backTop"). Bind ("click",function (e) {
- E.preventdefault ();
- $ ("Html,body"). ScrollTop (0)});
- };
- Back to Top
- var __tip=function (type,tiptext) {
- var surveytip=$ ("#D_SurveyTip"), surveymask=$ ("#D_SurveyMask");
- if (!surveytip| |! Surveymask) {return}
- Surveytip.removeclass ("warning Success"). AddClass (type). HTML (TipText);
- Surveymask.css ("display","block");
- Surveytip.css ("display","block");
- SetTimeout (function () {
- SURVEYMASK.CSS ("Display","None"); &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;SURVEYTIP.CSS ("Display","none")},1000)
- };
- IE6 compatible
- var __ie6fixed=function () {
- if (ieversion!==6) {return}
- var surveybox=$ ("#D_SurveyBox");
- var pubfeedback=$ ("#pubFeedBack");
- if (!surveybox| |! Pubfeedback)
- {
- return
- }
- $ (window). Bind ("scroll",function () {
- var h=$ (window). Height (), st=$ (window). scrolltop (),_top=h+st-options.height; var _top1=h+st-pubfeedback.height () -15;surveybox.css ("Top", _top+"px");
- Pubfeedback.css ("Top", _top1+"px")
- })
- };
- Start execution
- if (screen.width>=1280)
- {
- (function () {
- __feedcreat (); __ Initevent () }) ()
- }
- }
- }) (JQuery);
- window.onerror=function () {return false};
- if ($.isfunction (document). Survey)) {$ (document). Survey ()}
[CSS]View Plaincopyprint?
- #backTop I,#callSurvey i{background:URL (survey.png) no-repeat;}
- #pubFeedBack {position:fixed; _position:absolute;right:15px;bottom:15px;width:54px; Font-size:12PX;}
- #backTop,#callSurvey {display:block; Width:52px; padding:1px; Height:56px; Line-height:22px; Text-align:Center; Color:#fff; Text-decoration:none;}
- #backTop {display:none; Background:#999;}
- #backTop: hover{background:#ccc; zoom:1; Text-decoration:none; Color:#fff;}
- #backTop i{display:block; Width:25px; Height:13px; Margin:14px auto 8px; Background-position:-63px 0;}
- #callSurvey {margin-top:1px; Background:#3687d9;}
- #callSurvey: hover{background:#66a4e3; zoom:1; Text-decoration:none; Color:#fff;}
- #callSurvey i{display:block; Width:26px; Height:25px; Margin:9px auto 0; Background-position:0 0;}
- #callSurvey: Hover i{background-position:-30px 0;}
jquery JavaScript back to top features