`
lovecontry
  • 浏览: 1036923 次
文章分类
社区版块
存档分类
最新评论

[技术学习]WEB技术学习总结1

 
阅读更多
<!-- /*<! [CDATA[*/ body { color: #000; background-color: #fff; margin: 0px 10%; min-width: 720px; font-family: Verdana, sans-serif; counter-reset: chapter section subsection subsubsection paragraph lchapter lsection lsubsection lsubsubsection lparagraph} div.footnote { border-left: 1px solid #000; margin-left: 0em; clear: both } div.ftext { position: relative; margin-left: 50px } div.fnumber { float: left; width: 40px; padding: 0em; margin-left: 0.5em; margin-top: 0em } div.fnumber a { margin: 0px; padding: 0px } div.ctext { position: relative; margin-left: 100px } div.cnumber { float: left; width: 90px; padding: 0em; margin-left: 0.5em; margin-top: 0em } div.cnumber a { margin: 0px; padding: 0px } div.tip { border: 2px solid #0d0; margin: 0.5em 2em 1em 2em; padding: 0em 1em } div.warning, div.caution, div.danger, div.error { border: 2px solid #f00; margin: 0.5em 2em 1em 2em; padding: 0em 1em } div.note, div.hint, div.important { border: 2px solid #000; margin: 0.5em 2em 1em 2em; padding: 0em 1em } div.figure { display: block; padding: 1em; width: 400px; clear: both} div.topic { margin: 2em } div.vstsidebar, div.sidebar { border: 2px solid #aaa; color: #000; background-color: #ffffee; float: right; width: 40%; margin-left: 1em; margin-right: -1em; padding: 1em } span.strike { text-decoration: line-through } span.big { font-size: large } span.small { font-size: small } span.title { font-style: italic } span.notetitle { font-size: large; font-weight: 900; font-family: Verdana, sans-serif } p.toc { font-size: large; font-weight: 900 } p.notesubtitle { font-weight: 900; font-family: Verdana, sans-serif } p.attribution { font-style: italic; margin-left: 8em; text-indent: -1.4em } .vstright { float: right; margin: 1em } .vstleft { float: left; margin: 1em } .vstcenter { margin: 1em auto } blockquote.pull { font-size: large } p.rubric { font-size: large; margin-left: 2em } dd.normal { margin-bottom: 0.5em } dt.option { float: left; margin: 0em 0em 5px 2em; padding: 0px; font-family: monospace } dd.option { padding: 0px; margin: 0em 0em 5px 10em; text-indent: 0.5em } dd.option > p { margin: 0px } dd.normal > p { margin: 0px } table { border-collapse: collapse; margin: 0.5em 0em } thead, tfoot { text-align: center; font-weight: bold } td { border: 1px solid #000; padding: 0.25em; _top: 0%; vertical-align: top } td blockquote p{ margin: 0px; padding: 0px} td blockquote { margin: 0px; padding: 0px} table.vstbless td { border: 0px solid #000; padding: 0.25em; _top: 0%; vertical-align: top } td > p { margin: 0px } table.field { border: 0px solid #000; margin-left: 2em; padding: 0.25em; _top: 0%; vertical-align: top } td.fkey { font-weight: 900 } td.fval { border: 0px solid #000; padding: 0.25em; _top: 0%; vertical-align: top } td.fkey { font-weight: 900; border: 0px solid #000; padding: 0.25em; _top: 0%; vertical-align: top } td.fdkey { text-align: center; font-weight: 900 } td.fdval { text-align: center; font-style: italic } td.fakey { text-align: center; font-weight: 900 } td.faval { border: 0px solid #000; padding: 0.25em; _top: 0%; vertical-align: top } hr { width: 100%; margin: 1.5em auto } h1 { text-align: center; clear: both } h2, h3, h4, h5, h6 { text-align: left; margin-top: 1em; clear: both } h2 { counter-reset: section subsection subsubsection paragraph } h3 { counter-reset: subsection subsubsection paragraph } h4 { counter-reset: subsubsection paragraph } h5 { counter-reset: paragraph } h1 a { color: #000; background-color: transparent } h2 a { color: #000; background-color: transparent } h3 a { color: #000; background-color: transparent } h4 a { color: #000; background-color: transparent } h5 a { color: #000; background-color: transparent } h6 a { color: #000; background-color: transparent } p.subh1 { text-align: center; font-size: 120%; font-variant: small-caps } p.subh2, p.subh3, p.subh4, p.subh5, p.subh6 { text-align: left; font-size: 120%; font-variant: small-caps } h2:before { content: counter(chapter)" "; counter-increment: chapter } h3:before { content: counter(chapter)"."counter(section)" "; counter-increment: section } h4:before { content: counter(chapter)"."counter(section)"."counter(subsection)" "; counter-increment: subsection } h5:before { content: counter(chapter)"."counter(section)"."counter(subsection)"."counter(subsubsection)" "; counter-increment: subsubsection } h6:before { content: counter(chapter)"."counter(section)"."counter(subsection)"."counter(subsubsection)"."counter(paragraph)" "; counter-increment: paragraph} li.h1 { margin-left: 0em } li.h2 { margin-left: 1em; counter-reset: lsection lsubsection lsubsubsection lparagraph } li.h3 { margin-left: 2em; counter-reset: lsubsection lsubsubsection lparagraph } li.h4 { margin-left: 3em; counter-reset: lsubsubsection lparagraph } li.h5 { margin-left: 4em; counter-reset: lparagraph } li.h2:before { content: counter(lchapter)" "; counter-increment: lchapter } li.h3:before { content: counter(lchapter)"."counter(lsection)" "; counter-increment: lsection } li.h4:before { content: counter(lchapter)"."counter(lsection)"."counter(lsubsection)" "; counter-increment: lsubsection } li.h5:before { content: counter(lchapter)"."counter(lsection)"."counter(lsubsection)"."counter(lsubsubsection)" "; counter-increment: lsubsubsection } li.h6:before { content: counter(lchapter)"."counter(lsection)"."counter(lsubsection)"."counter(lsubsubsection)"."counter(lparagraph)" "; counter-increment: lparagraph} li.h6 { margin-left: 5em } ol, ul { margin-bottom: 0.5em; margin-top: 0.5em } ol.loweralpha { list-style-type: lower-alpha } ol.upperalpha { list-style-type: upper-alpha } ol.lowerroman { list-style-type: lower-roman } ol.upperroman { list-style-type: upper-roman } ol.decimal { list-style-type: decimal } ul.square { list-style-type: square } ul.circle { list-style-type: circle } ul.disc { list-style-type: disc } li > p { margin: 0em } img { border: 1px solid #000; padding: 0em; display: block; margin: 1em auto } img.inline { border: 1px solid #000; padding: 0em; margin: 0em; display: inline } pre { color: #000; background-color: #eee; margin-left: 2em; clear: both; overflow: auto } div.unknown { font-family: monospace; color: #000; background-color: #fff; margin: 1em; padding: 1em; clear: both; border: 3px solid red} pre.quoted { color: #000; background-color: #eee; margin-left: 0em; clear: both; overflow: auto } pre.rawlatex { color: #000; background-color: #ddd; border: 1px solid #000; padding: 0.1em; clear: both; overflow: auto } pre.address { font-family: Verdana, sans-serif; display: inline; margin: 0px; color: #000; background-color: #fff; overflow: auto } span.target { text-decoration: underline } div.vstfooter hr { width: 100%; margin: 0px } div.vstfooter p { margin: 0px } /*]]>*/ --> <!-- /*<! [CDATA[*/ .tohtml-javascript moring { color: #808080; background-color: #ffffff; font-family: monospace; } .tohtml-javascript moring .Statement { color: #ffff00; } .tohtml-javascript moring .Constant { color: #ff6060; } .tohtml-javascript moring .Comment { color: #8080ff; } .tohtml-javascript moring .Identifier { color: #00ffff; } /*]]-->

最近在读<<JavaScript Dom编程艺术>>(http://www.douban.com/subject/1921890/)一书,总结了一部分有价值的设计思想。

网页可以由以下三个层次构成一个共同体:

  • 结构层

  • 表示层

  • 行为层

结构层: 网页的结构层是由HTML或XHTML之类的标记语言负责创建。标签对网页内容的语义含义做出了描述,但这些标签不包含任何关于如何有关内容的信息。

表示层: 网页的表示层由CSS负责创建。CSS对“如何显示有关内容”的问题做出了回答。

行为层: 网页的行为层负责回答“内容应该如何对事件 做出反应”这一问题,这一层主要通过JavaScript和DOM技术来实现。

设计一个网站或者WEB应用程序 ,需要按照结构、表示、行为三个层次对内容进行分离。这意味着:
  • 使用(X)HTML去搭建文档的结构。

  • 使用CSS去设置文档的呈现效果。

  • 使用DOM脚本去实现文档的行为。

这本书还介绍每一个层次的分离方法:结构层和行为层的分离是比较简单,CSS本身提供了一系列机制来对HTML内容添加显示样式。本书作者重点介绍了结构层(HTML)和行为层(JS脚本)分离的方法。 如对于如下的HTML文件 test.html:

  <body>
<div id="imagegallery">
<a href="www.a.com"/>

<b href="www.b.com"/>

<b href="www.b.com"/>
</div>
</body>
</html>

可以将网页中的动作分离到以下的JS文件test.js:
////////////////////////////////////////////////////////////////////////
// 为每个a标签添加点击动作
functionprepareGallery(){
vargallery = document.getElementById("imagegallery");
varlinks = gallery.getElementsByTagName("a");

for(vari = 0; i < links.length; i++){
links[i].onclick = function(){
returnshowPic(this);
}
}
}

// addLoadEvent用于添加在页面加载完毕时执行的函数
functionaddLoadEvent(func){
varoldonLoad = window.onload;
if(typeofwindow.onload != 'function'){
window.onload = func;
}else{
window.onload = function(){
oldonload();
func();
}
}
}

addLoadEvent(prepareGallery);
////////////////////////////////////////////////////////////////////////

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics