ImageView 的setImageBitmap 设置的是图片实际宽高 而setImageDrawable()得到的是计算分辨率以后的。
关于ImageView只监MotionEvent.ACTION_DOWN事件,把返回值改为true后可以解决该问题 但是他的上层onclickListener

做一个有趣的人
ImageView 的setImageBitmap 设置的是图片实际宽高 而setImageDrawable()得到的是计算分辨率以后的。
关于ImageView只监MotionEvent.ACTION_DOWN事件,把返回值改为true后可以解决该问题 但是他的上层onclickListener
今天花了几个小时终于搞定了,把网站从主机屋搬迁到了新浪sae。写这些东西确实有点小菜,老鸟莫笑。首先分析一下难点在哪里。主机屋是普通的虚拟主机,搭建的时候只要把数据库导入数据库,然后把网站上传到服务器上就可以了。但是sae的架构不一样,但是理解起来也简单。sae采用的是分布式的架构,你的资源和你的数据库是保存在别的服务器上的,比如其附件是单独存在saestorage中,不能存放在代码目录中的,这些问题我想还好理解。同时也理解了大型应用是如何处理这些压力的。
废话少说,首先通过ftp把主机屋上的网站下载到本地。数据库通过主机屋提供的 PHPMyAdmin进行全部备份到本地。如果不确定有没有没问题的话可以先在本地搭建环境跑一边。
然后创建一个php应用 具体教程在这里
http://sae.sina.com.cn/?m=devcenter&catId=20
但是。。。。。 sae如果直接装我们自己搭建的wordpress会有很多问题的,因为它是分布式的架构,一种简便的方法是我们之间创建一个WordPress for SAE 地址在:http://sae.sina.com.cn/?m=apps&a=detail&aid=1
安装完成后我们找到创建的应用〉服务管理〉管理Mysql 进入phpMyAdmin管理界面 里面的表全删掉,然后导入我们 之前从主机屋上备份的sql文件。
然后在本地创建一个空文件夹,用TortoiseSVN迁出版本库中的文件到空白文件夹中。svn具体教程在
http://sae.sina.com.cn/?m=devcenter&a=index&catId=212
下一步我把我们之前本地的网站中的 wp-contentuploads文件夹单独剪切出来,其它文件拷贝到版本库中,(就是你迁出的那个默认目录是 1) 注意同名不要覆盖掉版本库中的文件,然后commit 到服务器上。
然后利用另外一个工具cyberduck 把文件提交到saeStorage中,
也可以在
下载地址:
http://src.sae.sinacdn.com/clients/Cyberduck-Installer-4.2.1.exe
使用方法
http://sae.sina.com.cn/?m=devcenter&catId=204&content_id=375
同时可以在服务管理〉storage中查看更多内容。。
最后 如果少的话慢慢修改你文章中 相册中的附件地址吧(要改成storage中的地址,比如
http://应用名-wordpress.stor.sinaapp.com/uploads/xxx.jpg)。如果多的用sql要快很多(这个你就自己去写吧).
把Apache2.2与Tomcat6进行整合之后,当提交带有中文参数的请求时,经常出现奇怪的现象。在直接访问Tomcat时,可以正常返回结果的请求,一旦经过Apache的代理,就出现问题。
通过Debug发现,Tomcat在经过和不经过Apache代理的两种情况下,得到的中文参数是不同的,而后者是乱码。
从网上查了一下资料,发现Apache在使用AJP13模式代理到Tomcat时,也应该为Tomcat的AJP13设定一些参数。
具体说来,应该在Tomcat的server.xml中设置为:
<Connector port=”8085″ protocol=”HTTP/1.1″ connectionTimeout=”20000″ redirectPort=”8443″
<!– 防止中文乱码 –>
useBodyEncodingForURI=”true” URIEncoding=”UTF8″ />
<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″
<!– 防止中文乱码 –>
useBodyEncodingForURI=”true” URIEncoding=”UTF8″ />
三个属性都用来适应视图的水平或垂直大小,一个以视图的内容或尺寸为基础的布局比精确地指定视图范围更加方便。
1)fill_parent
设置一个构件的布局为fill_parent将强制性地使构件扩展,以填充布局单元内尽可能多的空间。这跟Windows控件的dockstyle属性大体一致。设置一个顶部布局或控件为fill_parent将强制性让它布满整个屏幕。
2) wrap_content
设置一个视图的尺寸为wrap_content将强制性地使视图扩展以显示全部内容。以TextView和ImageView控件为例,设置为wrap_content将完整显示其内部的文本和图像。布局元素将根据内容更改大小。设置一个视图的尺寸为wrap_content大体等同于设置Windows控件的Autosize属性为True。
3)match_parent
Android2.2中match_parent和fill_parent是一个意思 .两个参数意思一样,match_parent更贴切,于是从2.2开始两个词都可以用。那么如果考虑低版本的使用情况你就需要用fill_parent了
android:layout_gravity
参考 http://wenku.baidu.com/view/12ca5929b4daa58da0114aea.html
android:background
android:layout_marginTop
android:layout_marginBottom
android:orientation
它确定了LinearLayout的方向,其值可以为
*vertical, 表示垂直布局
*horizontal, 表示水平布局
android:layout_gravity
同上。
android:layout_weight
关于设置android:layout_marginTop等属性失效
框架布局是直接覆盖在原图层上的。如果要定位我们需先设置 android:layout_gravity=”left”
然后再设置android:layout_marginTop等属性 否则无效
相对布局 RelativeLayout 允许子元素指定它们相对于其父元素或兄弟元素的位置,这是实际布局中最常用的布局方式之一。它灵活性大很多,当然属性也多,操作难度也大,属性之间产生冲突的的可能性也大,使用相对布局时要多做些测试。
下面是常用的一些属性
RelativeLayout用到的一些重要的属性:
第一类:属性值为true或false
android:layout_centerHrizontal 水平居中
android:layout_centerVertical 垂直居中
android:layout_centerInparent 相对于父元素完全居中
android:layout_alignParentBottom 贴紧父元素的下边缘
android:layout_alignParentLeft 贴紧父元素的左边缘
android:layout_alignParentRight 贴紧父元素的右边缘
android:layout_alignParentTop 贴紧父元素的上边缘
android:layout_alignWithParentIfMissing
第二类:属性值必须为id的引用名“@id/id-name”
android:layout_below 在某元素的下方
android:layout_above 在某元素的的上方
android:layout_toLeftOf 在某元素的左边
android:layout_toRightOf 在某元素的右边
android:layout_alignTop 本元素的上边缘和某元素的的上边缘对齐
android:layout_alignLeft 本元素的左边缘和某元素的的左边缘对齐
android:layout_alignBottom 本元素的下边缘和某元素的的下边缘对齐
android:layout_alignRight 本元素的右边缘和某元素的的右边缘对齐
第三类:属性值为具体的像素值,如30dip,40px
android:layout_marginBottom 离某元素底边缘的距离
android:layout_marginLeft 离某元素左边缘的距离
android:layout_marginRight 离某元素右边缘的距离
android:layout_marginTop 离某元素上边缘的距离
EditText的android:hint
设置EditText为空时输入框内的提示信息。
android:gravity
android:gravity属性是对该view 内容的限定.比如一个button 上面的text. 你可以设置该text 在view的靠左,靠右等位置.以button为例,android:gravity=”right”则button上面的文字靠右
android:layout_gravity
android:layout_gravity是用来设置该view相对与起父view 的位置.比如一个button 在linearlayout里,你想把该button放在靠左、靠右等位置就可以通过该属性设置.以button为例,android:layout_gravity=”right”则button靠右
android:layout_alignParentRight
使当前控件的右端和父控件的右端对齐。这里属性值只能为true或false,默认false。
android:scaleType:
android:scaleType是控制图片如何resized/moved来匹对ImageView的size。ImageView.ScaleType / android:scaleType值的意义区别:
CENTER /center 按图片的原来size居中显示,当图片长/宽超过View的长/宽,则截取图片的居中部分显示
CENTER_CROP / centerCrop 按比例扩大图片的size居中显示,使得图片长(宽)等于或大于View的长(宽)
CENTER_INSIDE / centerInside 将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽
FIT_CENTER / fitCenter 把图片按比例扩大/缩小到View的宽度,居中显示
FIT_END / fitEnd 把图片按比例扩大/缩小到View的宽度,显示在View的下部分位置
FIT_START / fitStart 把图片按比例扩大/缩小到View的宽度,显示在View的上部分位置
FIT_XY / fitXY 把图片不按比例扩大/缩小到View的大小显示
MATRIX / matrix 用矩阵来绘制,动态缩小放大图片来显示。
** 要注意一点,Drawable文件夹里面的图片命名是不能大写的。
布局文件是:
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android“
android:orientation=”horizontal”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>
<Button
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”Button1″
/>
<Button
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:layout_weight=”2″
android:text=”Button2″
/>
</LinearLayout>
出现的布局是:button1占了2/3,button2占了1/3。

但是如果将布局文件中的button的属性android:layout_width=”fill_parent”改为android:layout_width=”wrap_content”那么出现的结果为:button1占了1/3,button2占了2/3。

1 若get方式传送的数据编码错误可以尝试修改server.xml
<Connector port=”8080″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″ URIEncoding=”utf-8″ />
端口号也可以在这修改
项目中有很多小问题需要解决。一个是获取自动增长的数据。今天又解决了一个小问题。
就是在sql语句中若同时执行多条语句。我们是这样写的
insert into table1(name) values ('name');insert into table2(ID,group) values()
可是在作为一条语句执行时报错
check the manual that corresponds to your MySQL server version for the right….
解决办法如下
1、在MySQL的连接字符串中设置allowMultiQueries=true。
2、在程序中对SQL语句以分号拆分成多条SQL语句,然后使用Statement的addBatch方法,最后executeBatch就行。
希望给搜到这个问题的童鞋帮助
1、Mysql
在MySQL中,使用auto_increment类型的id字段作为表的主键。通常的做法,是通过“select max(id) from tablename”的做法,但是显然这种做法需要考虑并发的情况,需要在事务中对主表加以“X锁“,待获得max(id)的值以后,再解锁。这种做法需 要的步骤比较多,有些麻烦,而且并发性也不好。有没有更简单的做法呢?答案之一是通过select LAST_INSERT_ID()这个操作。乍一看,它和select max(id)很象,但实际上它是线程安全的。也就是说它是具体于数据库连接的。下面通过实验说明:
(1)、在连接1中向A表插入一条记录,A表包含一个auto_increment类型的字段。
(2)、在连接2中向A表再插入一条记录。
(3)、结果:在连接1中执行select LAST_INSERT_ID()得到的结果和连接2中执行select LAST_INSERT_ID()的结果是不同的;而在两个连接中执行select max(id)的结果是相同的。
其实在MSSQL中SCOPE_IDENTITY()和IDENT_CURRENT()的区别和这里是类似的。使用SCOPE_IDENTITY()可以 获得插入某个IDENTITY字段的当前会话的值,而使用IDENT_CURRENT()会获得在某个IDENTITY字段上插入的最大值,而不区分不同 的会话。
注:使用select last_insert_id()时要注意,当一次插入多条记录时,只是获得第一次插入的id值,务必注意!可以试试
2、sql
insert into book( Name,ISBN,Info)values(“sdaf”,”12345321236″,”asfadsfasfasdf”):select @@IDENTITY;
用sc create—-创建一个服务(增加到注册表中)
如下:在命令行模式下执行:
sc create TestService binpath= “c:in estapp.exe” displayname= “TestService” depend= Tcpip start= auto
注意这里的格式,“=”后面是必须空一格的,否则会出现错误。
在提示建立成功后,可以直接输入“net start TestService”
来启动服务,或者可以直接在“管理工具”的“服务”中直接启动。
C:Documents and SettingsAdministrator>sc create
描述:
在注册表和服务数据库中创建服务项。
用法:
sc <server> create [service name] [binPath= ] <option1> <option2>…
选项:
注意: 选项名称包括等号。
type= <own|share|interact|kernel|filesys|rec>
(默认 = own)
start= <boot|system|auto|demand|disabled>
(默认 = demand)
error= <normal|severe|critical|ignore>
(默认 = normal)
binPath= <BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <依存关系(以 / (斜杠) 分隔)>
obj= <AccountName|ObjectName>
(默认 = LocalSystem)
DisplayName= <显示名称>
password= <密码>
IE6中如何解决背景按钮为透明,加入以下样式:
1.针对IE6的filter滤镜法(适合个数比较少)
加入到样式里:
background: url(images/look.png) right bottom no-repeat;
_background:none; /*这个千万不能少,不然会有灰色的底色*/
_filter:progid:DXImageTransForm.Microsoft.AlphaImageLoader(src=’logo.png’,sizingMethod=’crop’);
/*不要忘了前面的_,因为是专门针对ie6的*/
sizingMethod : 可选项。字符串(String)。设置或检索滤镜作用的对象的图片在对象容器边界内的显示方式。
crop : 剪切图片以适应对象尺寸。
image : 默认值。增大或减小对象的尺寸边界以适应图片的尺寸。
scale : 缩放图片以适应对象的尺寸边界。
src : 必选项。字符串(String)。使用绝对或相对 url 地址指定背景图像。假如忽略此参数,滤镜将不会作用。
说明:
在对象容器边界内,在对象的背景和内容之间显示一张图片。并提供对此图片的剪切和改变尺寸的操作。如果载入的是PNG(Portable Network Graphics)格式,则0%-100%的透明度也被提供。
PNG(Portable Network Graphics)格式的图片的透明度不妨碍你选择文本。也就是说,你可以选择显示在PNG(Portable Network Graphics)格式的图片完全透明区域后面的内容。
add:这个方法我用的时候,如果想给这个元素再添加额外的背景色时,如果这么添加的话(background:red url(logo.png) no-repeat center;),别的浏览器正常识别,ie6会出现不识别的情况。
解决办法:1.background-color:red;单独写 2.加在外面套的标签上 3.body加背景色
2.DD_belatedPNG方法(推荐使用,非常适合整站IE6中PNG背景透明)
上面的方法很好用,但是有一个比较大的缺点,就是不支持CSS中backgrond-position与background-repeat。
而DD_belatedPNG,它支持backgrond-position与background-repeat,同时DD_belatedPNG还支持a:hover属性,以及<img>,所以可以说满足了我们所有的使用方法。
使用办法:
1.下载需要引入的js文件 见下面附上了
2.
<!–[if IE 6]>
<script src=”js/png.js”></script>
<script> DD_belatedPNG.fix(‘.pngfix’); </script>
<![endif]–>
上面这个插入在 <head> </head>之间,需要被透明的地方加上样式
以下附上png.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(‘.pngfix’); // 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();
总结:第一种用于单个控制比较方便,要是整站来的话,推荐第二种。
百度上看到的比较简单的一个例子引用过来
json数据为:
out.println("{name:'平凡的世界',author:'路遥'}");
ajax中,接收json数据时:
var result = request.responseText;
eval("var movie = " +result);
document.getElementById("div2").innerHTML = movie.name+":"+movie.author;
{name:'平凡的世界',author:'路遥'} 这是你服务器端返回的json字符串数据,那么你客户端你要怎么用呢,eval就是把一个字符串执行下,让普通的字符串变成一个对象(好像说得不是很贴切),就是普通字符执行后,里面的东西会变成可以直接使用的代码:如日期对象,数组。。。
eval("var movie = " +result); 这句意思就是把字符串变成可以直接使用的对象
执行后就相当于
var movie={name:'平凡的世界',author:'路遥'};把json对免赋值给movie变量
那么就可以直接引用了movie.name就是“平凡的世界”了movie.author就是“路遥”了,