HTML templates, which are displayed according to the link invocation page

Source: Internet
Author: User

Do site pages, find a variety of frameworks, but are not ideal, frameset bad control, iframe SEO optimization for the site is not good, has been a headache.

Later learned that you can use JS direct call, this use is the page load JS call, as follows:

$ ("#head"). Load ("head.html"); $ ("#foot"). Load ("foot.html");

But there is a problem, different page calls, then the image of the address how to write it? Of course there are solutions, such as node. JS, which is heard to be used, but not familiar.

Bored, and write their own, you can head, tail does not move, the intermediate content at any time call.

Tested, can be implemented, code attached:

Html:

<body><ul id= "list" ><li><a href= "javascript:void (0)" val= "1" target= "_blank" >11111</a ></li><li><a href= "javascript:void (0)" val= "2" target= "_blank" >22222</a></li> <li><a href= "javascript:void (0)" val= "3" target= "_blank" >33333</a></li><li><a href= "javascript:void (0)" val= "4" target= "_blank" >444444</a></li></ul><div id= "wrap" > </div></body>


Js:

$ (function () {<span style= "White-space:pre" ></span>var load_href;$ ("#list li a"). Click (function () {var val=$ (This). attr ("Val"), Console.log (Val), switch (val) {case "1": load_href= "111"; Break;case "2": load_href= "222"; break;} Console.log (LOAD_HREF); $ ("#wrap"). Load ("page/" +load_href+ ". html")})

Self-test, with a switch, of course, there are many ways to achieve, such as If-else,json.

Records for later inspection.

HTML templates, which are displayed according to the link invocation page

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.