Home  >  Article  >  Web Front-end  >  html模板,根据链接调用页面展示_html/css_WEB-ITnose

html模板,根据链接调用页面展示_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:49:561128browse

做网站页面,查找各种框架,但都不理想,frameset不好控制,iframe对于网站SEO优化不怎么好,一直很头疼。

后来得知可以使用js直接调用,本使用的是页面加载js调用,如下:

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

但又有问题了,不同页面调用,则图片的地址如何书写呢?当然这是有解决办法的,比如node.js,听说可以使用的,但不怎么熟悉。

百无聊赖之余,自己动手写写,可以将头、尾不动,中间内容随时调用。

经测试,可以实现,代码附上:

html:

		

js:

$(function(){			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")			})					})


自己测试,用的是switch,当然还有很多种方法实现,比如if-else,json等。

记录,以备之后查阅。









Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn