jquery Ajax Browsing Background features (1/2)

Source: Internet
Author: User

Intercepts the string required for the first occurrence in the passed-in string. The content between Fieldname+tag and Endtag

function GetQueryString (Url,fieldname,tag,endtag) {
var urlstring = Url;//document.location.href;
if (urlstring!= null) {
var typequ = Fieldname+tag;
var urlend = Urlstring.indexof (typequ);
if (urlend!=-1) {
var paramsurl = urlstring.substring (urlend+typequ.length);
var isend = Paramsurl.indexof (Endtag);
if (isend!=-1) {return paramsurl.substring (0, isend);}
Else{return Paramsurl;}
}
else {return null;}
}
Else{return null;}
}
Set the default page
function Setdefaultpage () {
$ ("#contul ul"). html ("");
$ ("#contul"). Hide ();
$ ("#cont"). Show ();
$ ("#top span"). FIND ("a"). Removeclass ("active");
$ ("#top span:eq (0)"). Find ("a"). AddClass ("active");
}
Detecting final characters
function Checkcode (getparme) {
if (getparme!=null) {
Getparme=getparme.touppercase ();
var codenum=getparme.charcodeat (0)
}
if (codenum>=65&&codenum<=91) {
$ ("#top span"). FIND ("a"). Removeclass ("active");
Alert ((codenum-64));
$ ("#top Span:eq (" + (codenum-64) + ")"). Find ("a"). AddClass ("active");
$ ("#cont"). HTML ("");
$ ("#cont"). Hide ();
$ ("#contul"). Find ("UL"). html ("");
Runajaxgetcode (Getparme);
}else{
Setdefaultpage ();
}
}
Performing AJAX operations
function Runajaxgetcode (getparme) {
$ ("#cont"). Fadeout (' Fast ', function () {
$.ajax ({
Cache:false,
Type: ' Get ',
URL: ' Sxml/searchbyword ' +getparme+ '. xml ',
Beforesend:function (XMLHttpRequest) {
$ (' <div class= quick-alert ' > Data loading, please </div> ' later)
. InsertBefore ($ ("#cont"))
. Fadein (' slow ');
},
Success:function (data,textstatus) {
$ ("#contul"). Show (). FIND ("UL"). html ("");
$ (". Quick-alert"). Fadeout (' Slow ', function () {
$ (this). Remove ();
$ ("item", data). Each (function (i, Domele) {
$ ("#contul ul"). Append ("<li><a href= '" +$ (Domele). Children ("link"). Text () + "' >" +getparme+ ": +$ (Domele) . Children ("title"). Text () + "</a></li>");
if (($ (this). Index ()-6)%6==0) {
$ ("#contul ul"). Append ("<div class= ' Clear ' ></div>");
}
});
});
},
Error:function () {
Alert ("Sorry, data acquisition failed, please F5 refresh the page and try again if the problem persists please contact the site administrator to resolve it.") ");
}
});
// });
}
Get parameters
function Getparmeter () {
Getparme=getquerystring (Urlparem, ' #网页特效 =tagcode ("', ', ', ') ');
Checkcode (Getparme);
}
Getparmeter ();
Click Trigger
$ ("#top span:gt (0)"). Click (function () {
$ (". Quick-alert"). Remove ();
});
Class
$.history.init (function (URL) {
Load (url = ""?) 1 ": URL);
if (url.length>0) {
Getparme=getquerystring (URL, ' Javascript=tagcode ("', ', ', ') ');
if (getparme!=null) {
Getparme=getparme.touppercase ();
Checkcode (Getparme);
}
}
else{
Setdefaultpage ();
}
});
Other actions on the page
var getparme;
function Gethash () {
var curhash = Location.hash;
alert (Curhash);
//}
var Urlparem;
Urlparem=document.location.href;
var tophtml;
var tophtmllink= "";
var $_objtop;
$_objtop=$ ("#top")
Tophtml=$_objtop.html ();
for (var i=65;i <91;i++)
{
tophtmllink+= "<span><a href= ' #javascript =tagcode (" "+ (String.fromCharCode (i+32)) +" ") ' > ' + String.fromCharCode (i) + "</a></span>";
}
$_objtop.html (Tophtml+tophtmllink);

Home 1 2 last page
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.