-------------------------------------------------------------------
@NotFound(action=NotFoundAction.IGNORE)使用hibernate
注解配置實體類的關聯關系,在many-to-one,one-to-one關聯中,一邊引用自另一邊的屬性,如果屬性值為某某的數據在數據庫不存在了,hibernate默認會拋出異常。解決此問題,加上如下注解就可以了:
@NotFound(action=NotFoundAction.IGNORE),意思是找不到引用的外鍵數據時忽略,NotFound默認是exception
-------------------------------------------------------------------cascade = CascadeType.REFRESH,cascade=CascadeType.ALL
cascade表示級聯操作
CascadeType.MERGE級聯更新:若items屬性修改了那么order對象保存時同時修改items里的對象。對應EntityManager的merge方法
CascadeType.PERSIST級聯刷新:獲取order對象里也同時也重新獲取最新的items時的對象。對應EntityManager的refresh(object)方法有效。即會重新查詢數據庫里的最新數據
CascadeType.REFRESH級聯保存:對order對象保存時也對items里的對象也會保存。對應EntityManager的presist方法
CascadeType.REMOVE級聯刪除:對order對象刪除也對items里的對象也會刪除。對應EntityManager的remove方法
CascadeType.PERSIST只有A類新增時,會級聯B對象新增。若B對象在數據庫存(跟新)在則拋異常(讓B變為持久態)
CascadeType.MERGE指A類新增或者變化,會級聯B對象(新增或者變化)
CascadeType.REMOVE只有A類刪除時,會級聯刪除B類;
CascadeType.ALL包含所有;
CascadeType.REFRESH沒用過。
綜上:大多數情況用CascadeType.MERGE就能達到級聯跟新又不報錯,用CascadeType.ALL時要斟酌下CascadeType.REMOVE
@Fetch:
定義了加載關聯關系的獲取策略. FetchMode 可以是
SELECT (在需要加載關聯的時候觸發select操作), SUBSELECT(只對集合有效,使用了子查詢策略,詳情參考Hibernate參考文檔)
JOIN (在加載主實體(owner entity)的時候使用SQL JOIN來加載關聯關系).
JOIN 將覆寫任何延遲屬性 (通過 JOIN策略加載的關聯將不再具有延遲性).
-------------------------------------------------------------------fetch=FetchType.LAZYHibernate的數據加載方式: 1.即時加載 immediately loading 實體加載完成后,立即加載其關聯的數據。
2.延遲加載lazy loading
實體相關聯的數據在第一次訪問時再進行讀取。
3.預先加載 eager loading
與immediately loading類似,但實體和相關聯的數據是通過一條sql同時讀取。
4.批量加載 batch loading
?
------------------------------------------------------------------
EntityManager 的API
下面是EntityManager的一些主要的接口方法:
void
persist(Object entity)
通過調用EntityManager的persist()方法,新實體實例將轉換為受控狀態。這意謂著當persist()方法所在的事務提交時,實體的數據將保存到數據庫中。如果實體已經被持久化,那么調用persist()操作不會發生任何事情。如果對一個已經刪除的實體調用persist()操作,刪除態的實體又轉變為受控態。如果對游離狀的實體執行persist()操作,將拋出IllegalArgumentException。 在一個實體上調用persist()操作,將廣播到和實體關聯的實體上,執行相應的級聯持久化操作;
void
remove(Object entity)
通過調用remove()方法刪除一個受控的實體。如果實體聲明為級聯刪除(cascade=REMOVE 或者cascade=ALL ),被關聯的實體也會被刪除。在一個新建狀態的實體上調用remove()操作,將被忽略。如果在游離實體上調用remove()操作,將拋出IllegalArgumentException,相關的事務將回滾。如果在已經刪除的實體上執行remove()操作,也會被忽略;
void
flush()
將受控態的實體數據同步到數據庫中;
T
merge(T entity)
將一個游離態的實體持久化到數據庫中,并轉換為受控態的實體;
T
find(Class entityClass, Object primaryKey)
以主鍵查詢實體對象,entityClass是實體的類,primaryKey是主鍵值,如以下的代碼查詢Topic實體: Topic t = em.find(Topic.class,1); Query createQuery(String qlString) 根據JPA的查詢語句創建一個查詢對象Query,如下面的代碼:
Query q= em.createQuery(""SELECT t FROM Topic t WHERE t.topicTitle LIKE :topicTitle")"); Query createNativeQuery(String sqlString)
使用本地數據庫的SQL語句創建一個Query對象,Query通過getResultList()方法執行查詢后,返回一個List結果集,每一行數據對應一個Vector。
使用本地數據庫的SQL語句創建一個Query對象,Query通過getResultList()方法執行查詢后,返回一個List結果集,每一行數據對應一個Vector。
看來要學習的東東還有好多啊~~努力吧!
posted @
2013-03-05 11:51 老天 閱讀(3893) |
評論 (1) |
編輯 收藏
1、@Transient 使用場景:一般在模型中對應某一個字段的屬性中的set和get方法中。作用是數據與數據庫中不一一對應。如:
/*@Transient public String getModulename() {
return modulename;
}
public void setModulename(String modulename) {
this.modulename = modulename;
}*/
2、@ManyToOne
多對一。可以把另一個模型對應過來。在查詢時,無需要聯表查詢。
@JoinColumn(name="moduleid",insertable=false,updatable=false)
@NotFound(action=NotFoundAction.IGNORE)
public CateModule getCateModule() {
return cateModule;
}
public void setCateModule(CateModule cateModule) {
this.cateModule = cateModule;
}
posted @
2012-12-03 11:09 老天 閱讀(244) |
評論 (0) |
編輯 收藏
private Object filterHTMLTag(Object obj) throws Exception{
if(obj==null) return obj;
Class objCls=obj.getClass();
Field[] allFields=objCls.getDeclaredFields();
if(allFields!=null && allFields.length!=0){
HTMLFilter filter=new HTMLFilter();
for(Field field: allFields){
if(field!=null){
if(field.getType().equals(String.class)){
String getMethod="get"+upperCaseFirstChar(field.getName());
String setMethod="set"+upperCaseFirstChar(field.getName());
try {
//String value=(String)objCls.getMethod(getMethod).invoke(obj);
//value=filter.filter(value);
//objCls.getMethod(setMethod, value.getClass()).invoke(obj, value);
} catch (Exception e) {
throw e;
}
}
}
}
}
return obj;
}
posted @
2012-12-03 10:49 老天 閱讀(239) |
評論 (0) |
編輯 收藏
ALTER TABLE "public"."base_contract"
ADD COLUMN "isrejected" int2 DEFAULT 0 NOT NULL;
ALTER TABLE "public"."base_contract"
ADD COLUMN "userid" int8 DEFAULT 0 NOT NULL;
ALTER TABLE "public"."base_user"
ADD COLUMN "telphone" varchar(20) DEFAULT ''::character varying NOT NULL;
INSERT INTO "base_role" VALUES ('21', '代理商', '只能查看對屬于自己的所有合同');
update base_contract a set userid=(SELECT b.userid from base_user b where a.username=b.username LIMIT 1)
delete from base_menu;
BEGIN;
INSERT INTO "base_menu" VALUES ('1', 'infoMenu', null, '公用菜單', null, null, null, null, 'Y', '0');
INSERT INTO "base_menu" VALUES ('2', 'ediUser', 'infoMenu', '修改個人資料', 'Note', 'ediUser.jsp', 'top', '2', 'N', '0');
COMMIT;
posted @
2012-11-28 18:21 老天 閱讀(368) |
評論 (1) |
編輯 收藏
一:if指令:
<#if condition>...
<#elseif condition2>...
<#elseif condition3>...
...<#else>...
</#if>
二:switch
<#switch value>
<#case refValue1>...<#break>
<#case refValue2>...<#break>...
<#case refValueN>...<#break>
<#default>...</#switch>
三:list,break
<#list sequence as item>
...
</#list>
兩個特殊的循環變量:
item_index: 當前變量的索引值。
item_has_next: 是否存在下一個對象。
可以用<#break/>指令離開loop循環。
四:include指令
<#include filename>或者
<#include filenameoptions>
filename: 表達式轉換為字符串
options: encoding=encoding, parse=parse encoding: 表達式轉換為字符串
parse: 表達式轉換為邏輯值,是否作為ftl文件解析。
<#include "/common/navbar.html" parse=false encoding="Shift_JIS">
<#include "*/footer.ftl">表示當前目錄下以及所有父目錄下的文件。如果當前模版在/foo/bar/template.ftl ,那么查找footer.ftl的順序為:/foo/bar/footer.ftl
/foo/footer.ftl/footer.ftl這種方式講允許設計者將通用的模版放在父文件夾里面。
也可以只指定部分路徑:<#include "*/commons/footer.ftl">
五:import指令<#import path as hash>
六:noparse
<#noparse>
...
</#noparse>
七:compress
<#compress>
...
</#compress>
八:escape,noescape
<#escape identifier as expression>
...
<#noescape>...</#noescape>
...
</#escape>
escape指令body區的ftl的interpolations都會被自動加上escape表達式。但是不會影響字符串內的interpolations。而且也只會影響到body內出現的interpolations,比如不會影響到include的ftl的interpolations。
<#escape x as x?html>
First name: ${firstName}
Last name: ${lastName}
Maiden name: ${maidenName}</#escape>
等同于:
First name: ${firstName?html}
Last name: ${lastName?html}
Maiden name: ${maidenName?html}
escape指令在解析模版時起作用,而不是運行時起作用。
escape指令還能嵌套使用,子繼承父的escape規則。
<#escape x as x?html>
Customer Name: ${customerName}
Items to ship:
<#escape x as itemCodeToNameMap[x]>
${itemCode1}
${itemCode2}
${itemCode3}
${itemCode4}
</#escape></#escape>
等同于:Customer Name: ${customerName?html}
Items to ship:
${itemCodeToNameMap[itemCode1]?html}
${itemCodeToNameMap[itemCode2]?html}
${itemCodeToNameMap[itemCode3]?html}
${itemCodeToNameMap[itemCode4]?html}
九:assign指令
<#assign name=value>or<#assign name1=value1name2=value2... nameN=valueN>or<#assign same as above... in namespacehash>or<#assign name> capture this</#assign>or<#assign name in namespacehash> capture this</#assign>創建或者替換一個已經存在的變量,只能作用于頂層變量。不好的做法:<#assign x>Hello ${user}!</#assign>更改為:<#assign x="Hello ${user}!">
十:global指令
<#global name=value>
or
<#global name1=value1name2=value2... nameN=valueN>or<#global name>
capture this
</#global>
十一:local指令
<#local name=value>
or
<#local name1=value1name2=value2... nameN=valueN>or<#local name>
capture this
</#local>只能用于macro的定義body中。
十二:setting指令:
<#setting name=value>
name的取值范圍:
local:number_format:
boolean_format:缺省值為"true,false"
date_format, time_format, datetime_format
time_zone:url_escaping_charset
classic_compatible
十三:用戶自定義指令
<@macro_or_transfparam1=val1param2=val2...paramN=valN/><@macro_or_transfparam1=val1param2=val2...paramN=valN ; lv1, lv2, ..., lvN/><@macro_or_transf...> ...</@macro_or_transf><@macro_or_transf...> ...</@><@macro_or_transfval1, val2, ..., valN/>
十四:macro,nested,return
<#macro nameparam1param2... paramN>
...
<#nested loopvar1, loopvar2, ..., loopvarN>
...
<#return>
...
</#macro>
十五:function, return
<#function nameparam1param2... paramN>
... <#return returnValue>
...
</#function>
<#function avg x y>
<#return (x + y) / 2>
</#function>
${avg(10, 20)}
十六:flush
<#flush>
十七:stop
<#stop>
or
<#stop reason>取消處理模版。
十八:ftl指令
<#ftl param1=value1param2=value2...paramN=valueN>
ftl指令必須放在ftl文件的最上面。
參數范圍:
encoding:
strip_whitespace
strip_text
strict_syntax
十九:t, lt, rt
二十:attempt, recover
<#attempt>
attempt block<#recover>
recover block
</#attempt>
<#attempt>
Optional content: ${thisMayFails}
<#recover>
Ops! The optional content is not available.
</#attempt>
posted @
2012-11-15 11:30 老天 閱讀(424) |
評論 (0) |
編輯 收藏
<!-- http://www.iefans.net/ie8-filteralpha-png-touming/
IE8里可以這樣寫 -ms-filter:”progid:DXImageTransform.Microsoft.Alpha(opacity=50)”;
IE7里可以這樣寫 filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);
IE6,IE7,IE8里都可以這樣寫 filter:alpha(opacity=50)
-->
from:http://unc0pyrightable.blog.163.com/blog/static/1313300602010021526561/
今天推薦一個最完美讓ie6支持png透明的js,為什么說它最完美呢?
只因為它支持background-position和background-repeat
這是市面上的其它方法比不上的
首先,要在網頁中引用js
<!--[if IE 6]>
<script src="http://www.dillerdesign.com/experiment/DD_belatedPNG/DD_belatedPNG_0.0.8a-min.js"></script>
<script>
DD_belatedPNG.fix('.png_bg');
</script>
<![endif]-->
上面那個js路徑是絕對路徑,大家最好還是把它下下來,以防網站掛了.
引用之后就是更改第二個<script>里的.png為你要實現效果的選擇器.
就比如,你#header引用了一個background,那你上面就要改為:
DD_belatedPNG.fix('#header');
并且它還支持組選擇器,如:
DD_belatedPNG.fix('#header,h1,h2,h3,#content');
很簡單吧,只要把有透明png的標簽或選擇器寫在里面就行
至于這里面能不能支持css3就不得而知了.
官網:http://www.dillerdesign.com/experiment/DD_belatedPNG/
這個JS內容(DD_belatedPNG_0.0.8a-min.js),備存:
/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/
var DD_belatedPNG={
ns:"DD_belatedPNG",imgSize:{
},delay:10,nodesFixed:0,createVmlNameSpace:function () {
if(document.namespaces&&!document.namespaces[this.ns]) {
document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")
}
},createVmlStyleSheet:function () {
var b,a;
b=document.createElement("style");
b.setAttribute("media","screen");
document.documentElement.firstChild.insertBefore(b,document.documentElement.firstChild.firstChild);
if(b.styleSheet) {
b=b.styleSheet;
b.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}");
b.addRule(this.ns+"\\:shape","position:absolute;");
b.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");
this.screenStyleSheet=b;
a=document.createElement("style");
a.setAttribute("media","print");
document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);
a=a.styleSheet;
a.addRule(this.ns+"\\:*","{display: none !important;}");
a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")
}
},readPropertyChange:function () {
var b,c,a;
b=event.srcElement;
if(!b.vmlInitiated) {
return
}if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1) {
DD_belatedPNG.applyVML(b)
}if(event.propertyName=="style.display") {
c=(b.currentStyle.display=="none")?"none":"block";
for(a in b.vml) {
if(b.vml.hasOwnProperty (a)) {
b.vml[a].shape.style.display=c
}
}
}if(event.propertyName.search("filter")!=-1) {
DD_belatedPNG.vmlOpacity(b)
}
},vmlOpacity:function (b) {
if(b.currentStyle.filter.search("lpha")!=-1) {
var a=b.currentStyle.filter;
a=parseInt(a.substring(a.lastIndexOf("=")+1,a.lastIndexOf(")")),10)/100;
b.vml.color.shape.style.filter=b.currentStyle.filter;
b.vml.image.fill.opacity=a
}
},handlePseudoHover:function (a) {
setTimeout(function () {
DD_belatedPNG.applyVML(a)
},1)
},fix:function (a) {
if(this.screenStyleSheet) {
var c,b;
c=a.split(",");
for(b=0;b<c.length;b++) {
this.screenStyleSheet.addRule(c[b],"behavior:expression(DD_belatedPNG.fixPng(this))")
}
}
},applyVML:function (a) {
a.runtimeStyle.cssText="";
this.vmlFill(a);
this.vmlOffsets(a);
this.vmlOpacity(a);
if(a.isImg) {
this.copyImageBorders(a)
}
},attachHandlers:function (i) {
var d,c,g,e,b,f;
d=this;
c={
resize:"vmlOffsets",move:"vmlOffsets"
};
if(i.nodeName=="A") {
e={
mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"
};
for(b in e) {
if(e.hasOwnProperty (b)) {
c[b]=e[b]
}
}
}for(f in c) {
if(c.hasOwnProperty (f)) {
g=function () {
d[c[f]](i)
};
i.attachEvent("on"+f,g)
}
}i.attachEvent("onpropertychange",this.readPropertyChange)
},giveLayout:function (a) {
a.style.zoom=1;
if(a.currentStyle.position=="static") {
a.style.position="relative"
}
},copyImageBorders:function (b) {
var c,a;
c={
borderStyle:true,borderWidth:true,borderColor:true
};
for(a in c) {
if(c.hasOwnProperty (a)) {
b.vml.color.shape.style[a]=b.currentStyle[a]
}
}
},vmlFill:function (e) {
if(!e.currentStyle) {
return
}else {
var d,f,g,b,a,c;
d=e.currentStyle
}for(b in e.vml) {
if(e.vml.hasOwnProperty (b)) {
e.vml[b].shape.style.zIndex=d.zIndex
}
}e.runtimeStyle.backgroundColor="";
e.runtimeStyle.backgroundImage="";
f=true;
if(d.backgroundImage!="none"||e.isImg) {
if(!e.isImg) {
e.vmlBg=d.backgroundImage;
e.vmlBg=e.vmlBg.substr(5,e.vmlBg.lastIndexOf('")')-5)
}else {
e.vmlBg=e.src
}g=this;
if(!g.imgSize[e.vmlBg]) {
a=document.createElement("img");
g.imgSize[e.vmlBg]=a;
a.className=g.ns+"_sizeFinder";
a.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";
c=function () {
this.width=this.offsetWidth;
this.height=this.offsetHeight;
g.vmlOffsets(e)
};
a.attachEvent("onload",c);
a.src=e.vmlBg;
a.removeAttribute("width");
a.removeAttribute("height");
document.body.insertBefore(a,document.body.firstChild)
}e.vml.image.fill.src=e.vmlBg;
f=false
}e.vml.image.fill.on=!f;
e.vml.image.fill.color="none";
e.vml.color.shape.style.backgroundColor=d.backgroundColor;
e.runtimeStyle.backgroundImage="none";
e.runtimeStyle.backgroundColor="transparent"
},vmlOffsets:function (d) {
var h,n,a,e,g,m,f,l,j,i,k;
h=d.currentStyle;
n={
W:d.clientWidth+1,H:d.clientHeight+1,w:this.imgSize[d.vmlBg].width,h:this.imgSize[d.vmlBg].height,L:d.offsetLeft,T:d.offsetTop,bLW:d.clientLeft,bTW:d.clientTop
};
a=(n.L+n.bLW==1)?1:0;
e=function (b,p,q,c,s,u) {
b.coordsize=c+","+s;
b.coordorigin=u+","+u;
b.path="m0,0l"+c+",0l"+c+","+s+"l0,"+s+" xe";
b.style.width=c+"px";
b.style.height=s+"px";
b.style.left=p+"px";
b.style.top=q+"px"
};
e(d.vml.color.shape,(n.L+(d.isImg?0:n.bLW)),(n.T+(d.isImg?0:n.bTW)),(n.W-1),(n.H-1),0);
e(d.vml.image.shape,(n.L+n.bLW),(n.T+n.bTW),(n.W),(n.H),1);
g={
X:0,Y:0
};
if(d.isImg) {
g.X=parseInt(h.paddingLeft,10)+1;
g.Y=parseInt(h.paddingTop,10)+1
}else {
for(j in g) {
if(g.hasOwnProperty (j)) {
this.figurePercentage(g,n,j,h["backgroundPosition"+j])
}
}
}d.vml.image.fill.position=(g.X/n.W)+","+(g.Y/n.H);
m=h.backgroundRepeat;
f={
T:1,R:n.W+a,B:n.H,L:1+a
};
l={
X:{
b1:"L",b2:"R",d:"W"
},Y:{
b1:"T",b2:"B",d:"H"
}
};
if(m!="repeat"||d.isImg) {
i={
T:(g.Y),R:(g.X+n.w),B:(g.Y+n.h),L:(g.X)
};
if(m.search("repeat-")!=-1) {
k=m.split("repeat-")[1].toUpperCase();
i[l[k].b1]=1;
i[l[k].b2]=n[l[k].d]
}if(i.B>n.H) {
i.B=n.H
}d.vml.image.shape.style.clip="rect("+i.T+"px "+(i.R+a)+"px "+i.B+"px "+(i.L+a)+"px)"
}else {
d.vml.image.shape.style.clip="rect("+f.T+"px "+f.R+"px "+f.B+"px "+f.L+"px)"
}
},figurePercentage:function (d,c,f,a) {
var b,e;
e=true;
b=(f=="X");
switch(a) {
case "left":case "top":d[f]=0;
break;
case "center":d[f]=0.5;
break;
case "right":case "bottom":d[f]=1;
break;
default:if(a.search("%")!=-1) {
d[f]=parseInt(a,10)/100
}else {
e=false
}
}d[f]=Math.ceil(e?((c[b?"W":"H"]*d[f])-(c[b?"w":"h"]*d[f])):parseInt(a,10));
if(d[f]%2===0) {
d[f]++
}return d[f]
},fixPng:function (c) {
c.style.behavior="none";
var g,b,f,a,d;
if(c.nodeName=="BODY"||c.nodeName=="TD"||c.nodeName=="TR") {
return
}c.isImg=false;
if(c.nodeName=="IMG") {
if(c.src.toLowerCase().search(/\.png$/)!=-1) {
c.isImg=true;
c.style.visibility="hidden"
}else {
return
}
}else {
if(c.currentStyle.backgroundImage.toLowerCase().search(".png")==-1) {
return
}
}g=DD_belatedPNG;
c.vml={
color:{
},image:{
}
};
b={
shape:{
},fill:{
}
};
for(a in c.vml) {
if(c.vml.hasOwnProperty (a)) {
for(d in b) {
if(b.hasOwnProperty (d)) {
f=g.ns+":"+d;
c.vml[a][d]=document.createElement(f)
}
}c.vml[a].shape.stroked=false;
c.vml[a].shape.appendChild(c.vml[a].fill);
c.parentNode.insertBefore(c.vml[a].shape,c)
}
}c.vml.image.shape.fillcolor="none";
c.vml.image.fill.type="tile";
c.vml.color.fill.on=false;
g.attachHandlers(c);
g.giveLayout(c);
g.giveLayout(c.offsetParent);
c.vmlInitiated=true;
g.applyVML(c)
}
};
try{
document.execCommand("BackgroundImageCache",false,true)
}catch(r) {
}DD_belatedPNG.createVmlNameSpace();
DD_belatedPNG.createVmlStyleSheet();
或者:
讓IE6支持PNG格式的圖片
用法:
先復制下面的代碼在記事本中,然后另存為pngbehavior.htc(名字可以任意):
<public:componentlightWeight="true">
<public:attach event="onpropertychange"onevent="propertyChanged()" />
<public:attach event="onbeforeprint"onevent="beforePrint()" for="window"/>
<public:attach event="onafterprint"onevent="afterPrint()" for="window"/>
<script>
var supported = /MSIE ((5\.5)|[6789])/.test(navigator.userAgent)&&
navigator.platform== "Win32";
var realSrc;
var blankSrc = "blank.gif";
var isPrinting = false;
if (supported) fixImage();
function propertyChanged() {
if (!supported || isPrinting) return;
var pName = event.propertyName;
if (pName != "src") return;
// if not set to blank
if (!new RegExp(blankSrc).test(src))
fixImage();
};
function fixImage() {
// get src
var src = element.src;
// check for real change
if (src == realSrc&& /\.png$/i.test(src)) {
element.src =blankSrc;
return;
}
if ( ! new RegExp(blankSrc).test(src)) {
// backup old src
realSrc = src;
}
// test for png
if (/\.png$/i.test(realSrc)) {
// set blank image
element.src =blankSrc;
// set filter
element.runtimeStyle.filter= "progid:DXImageTransform.Microsoft." +
"AlphaImageLoader(src='"+ src + "',sizingMethod='scale')";
}
else {
// remove filter
element.runtimeStyle.filter= "";
}
}
function beforePrint() {
isPrinting = true;
element.src = realSrc;
element.runtimeStyle.filter = "";
realSrc = null;
}
function afterPrint() {
isPrinting = false;
fixImage();
}
</script>
</public:component>
最后在你的css文件里面加上這么一段代碼:
img {
behavior: url("pngbehavior.htc");
}
posted @
2012-11-15 10:26 老天 閱讀(188) |
評論 (0) |
編輯 收藏