Posted on 2015-08-17 11:18
lxasp 阅读(376)
评论(0) 编辑 收藏 引用
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>html5兼容xml的编写更少代码的规范</title>
<style>
*{margin:0;padding:0}
</style>
</head>
<body>
<pre>
第一行DOCTYPE大写,html小写 ;
<br/>无子节点的标签,结束/>标签前不要额外空格 ;
&#169; 特殊字符用数字编码,而不用名字&copy; ;
标志型属性用readonly="1" disabled="1" selected="1" checked="1" ;
属性值一律使用双引号括起来 ;
脚本代码如果有服务器脚本的单独分开 ;
脚本代码格式如本文档的示例 ;
按钮一律使用<button而不用<input type="button"
</pre>
http://javascript-minifier.com
http://cssminifier.com
<br/>
<hr/>
<form id="form1" method="post" action="#">
<div class="fmfs">
<div class="fmf"><label>表单控件字段22</label><br/>
<input type="text" id="i22" readonly="1"/>
<button type="button" id="i22b" class="b" onclick="alert('i22')"></button>
</div>
</div>
</form>
版权字符 &#169;
<script>/*<![CDATA[/*pkmaster@2015q2*/
(function(WN,DC,UN){
var php=WN.$P?WN.$P:$P={};
<?php echo 'php["hello"]="hello world";'?>
})(this,document);
//]]></script>
<script>/*<![CDATA[/*pkmaster@2015q2*/
(function(WN,DC,UN){
var php=WN.$P?WN.$P:$P={};
DC.getElementById("i22").value=(UN!==php["hello"]?php["hello"]:"");
alert(UN!==php["und"]?php["und"]:"0");
})(this,document);
//]]></script>
</body>
</html>
页面内javascript代码书写示例:
(function(Win,Doc,Und){
var php=Win.$P?Win.$P:$P={};
php['v1']='1';
})(this,document);
(function(Win,Doc,Und){
var php=Win.$P?Win.$P:$P={};
php['v2']='2';
})(this,document);
(function(Win,Doc,Und){
var php=Win.$P?Win.$P:$P={};
alert(php['v2']===Und?php['v1']:!1);
})(this,document);