Enable the Ajax web page to have the backend Function

Source: Internet
Author: User
Enable the Ajax web page to have the backend Function

After creating a project in Ajax, the tester told me that after the news list has been turned over many pages, When I view the detailed information of a news record and return it to the directory, it is depressing that you cannot return a page number that has already been turned over from the first page. Find an article <develop an Ajax application that retains the standard browser function> on the Internet, and extract the corresponding code according to the description in the article.

My implementation principle is: each page is turned over, the current page number is saved to the fragment ID of the broken URL, and the customer will return to the directory after viewing the detailed information, in the onload event of the Directory body, execute setoptionvalue to get the fragment content, and then execute the function to read the directory to save the paging information.

// Use the part identifier of the URI to create a history of the status;
Function makehistory (newhash)
{
Window. Location. Hash = newhash;
Expectedhash = Window. Location. Hash;
Alert (expectedhash );
Return true;
}
// Check the URI in the browser history
Function handlehistory ()
{
If (window. Location. Hash! = Expectedhash)
{
Alert (window. Location. Hash + "|" + expectedhash );
Expectedhash = Window. Location. Hash;
VaR newoption = expectedhash;
Setoptionvalue (newoption );
}
Return true;
}

Function pollhash (){
Handlehistory ();
// Window. setinterval ("handlehistory ()", 1000 );
Return true;
}

// Obtain the content in the fragment and perform any operations
Function setoptionvalue (value)
{
// Var myform = Document. make_history;
// Var myselect = myform. change_year;
// Myselect. Options [value-1]. Selected = true;
Document. getelementbyidx ("testdiv"). innerhtml = value. Replace ('#','');
Test (value. Replace ('#',''));
Alert (value. Replace ('#',''));
Return true;
} # JavaScript/ajax Column

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.