ie6下png图片背景透明处理 |
js, ie6, png |
|
<!--[if IE 6]>
<script>
function correctPNG() {
for(var i=0; i<document.images.length; i++){
var img = document.images[i];
var imgName = img.src.toUpperCase();
if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
var imgID = (img.id) ? "id='" + img.id + "' " : "";
var imgClass = (img.className) ? "class='" + img.className + "' " : "";
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
var imgStyle = "display:inline-block;" + img.style.cssText;
if (img.align == "left") imgStyle = "float:left;" + imgStyle;
if (img.align == "right") imgStyle = "float:right;" + imgStyle;
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
var strNewHTML = "<span "+ imgID + imgClass + imgTitle + "style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src='" + img.src + "', sizingMethod='scale');\"></span>";
img.outerHTML = strNewHTML;
i = i-1;
}
}
}
window.attachEvent("onload", correctPNG);
</script>
<![endif]-->
|
Ajax服务器端代码 |
ajax, java |
|
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/xml;charset=utf-8");// (1)一定要在(2)的前面,不然会乱码
response.setCharacterEncoding("UTF-8"); // (2)
response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // prevents catching at proxy server
StringBuilder sb = new StringBuilder();
// Javascript语句,如(客户端使用eval(req.responseText);)
sb.append("document.getElementById(\"result\").value=\"success\";");
// html语句,如(客户端使用obj.innerHTML = req.responseText;)
sb.append("<div>success</div>");
// xml,如(客户端使用obj.value = req.responseXML.get("msg");)
sb.append("<msg>success</msg>");
PrintWriter out = response.getWriter(); // (3)一定要在(1)(2)的后面
out.write(sb.toString());
out.flush();
out.close();
|
Ajax客户端代码 |
js, ajax |
|
function ajax() {
var arg1= document.getElementById("arg1").value;
var arg2 = document.getElementById("arg2").value;
var url = "deal.jsp?arg1=" + escape(arg1) + "&arg2=" + escape(arg2);
// alert(url);
// 创建异步请求对象
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
// 发送请求
req.open("post", url, true);
// 返回后执行的方法
req.onreadystatechange = callback;
req.send(null);
}
function callback() {
if (req.readyState == 4) {
if (req.status == 200) {
// deal with the response text
// alert(req.responseText);
eval(req.responseText); // 如果返回的是js语句
//or
document.getElementById("result").innerHTML = req.responseText; // 如果返回的是纯html语句 //or
document.getElementById("result").value = req.responseXML.get("msg");; // 如果返回的是xml格式的信息
} else {
// 失败
alert(req.status + "\r\n" +req.responseText);
window.location = location;
}
}
}
|
通用css |
网页, css, 通用样式 |
|
/* 链接
初始状态: 蓝色(blue),无下划线
鼠标悬停: 橙色(#F30),无下划线*/
a:link {
color: blue;
text-decoration: none;
}
a:visited {
color: blue;
text-decoration: none;
}
a:hover {
color: #F30;
text-decoration: none;
}
/* float
左浮动,右浮动和无浮动*/
.float-left {
float: left;
}
.float-right {
float: right;
}
.float-none {
float: none;
}
/* 对齐方式
左对齐,右对齐和居中对齐*/
.left {
text-align: left;
}
.center {
text-align: center;
}
.right {
text-align: right;
}
/* clear*/
.clear {
clear: both;
}
/* 空行,高10px*/
.blank {
height: 10px;
}
|
网页布局 - wrapper |
css, 布局, 网页 |
山东大学威海分校庆祝山东大学建校110周年专题网站 |
body {
width: 900px; /* 页面宽度*/
text-align: center;
margin: 0 auto;
font-size: 12px;
background-color: #fff; /* 背景颜色,白色*/
}
#wrapper {
width: 900px; /* 页面宽度*/
margin: 0px auto;
text-align: left;
}
|
网页嵌入flash - 兼容IE,Chrome,FireFox |
网页, flash, object标签 |
山东大学威海分校 |
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1002" height="215" id="FlashID" title="banner">
<param name="movie" value="flash/banner.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="9.0.45.0" />
<!-- 此 param 标签提示使用 Flash Player 6.0 r65 和更高版本的用户下载最新版本的 Flash Player。如果您不想让用户看到该提示,请将其删除。 -->
<param name="expressinstall" value="flash/expressInstall.swf" />
<param name="SCALE" value="noborder" />
<!-- 下一个对象标签用于非 IE 浏览器。所以使用 IECC 将其从 IE 隐藏。 -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="flash/banner.swf" width="1002" height="215">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="9.0.45.0" />
<param name="expressinstall" value="flash/expressInstall.swf" />
<param name="SCALE" value="noborder" />
<!-- 浏览器将以下替代内容显示给使用 Flash Player 6.0 和更低版本的用户。 -->
<div>
<h4>此页面上的内容需要较新版本的 Adobe Flash Player。</h4>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="获取 Adobe Flash Player" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
|