修改下载的一个163edit编辑器,无法进行图片大小限制.特请教高手.请帮忙注释一下下面这段代码,并插入一段判断代码:如果图片宽度大于650,则令其等于650;如果小于650,则保持不变.
var sPhotos=document.getElementById('imagess').value;
if ((sPhotos!=null) && (sPhotos!="http://")){
format("InsertImage", sPhotos);
var f = window.frames["HtmlEditor"];
var aImage = f.document.getElementsByTagName("img");
for(var i=0; i<aImage.length;i++){
if (aImage[i].src == sPhotos){
aImage[i].style.width = "650px";
}
}
}
}发现不能用下面代码:onload='javascript:if(this.width > 650) this.width=650'
所以不要用这个.先谢谢了.
var sPhotos=document.getElementById('imagess').value;
if ((sPhotos!=null) && (sPhotos!="http://")){
format("InsertImage", sPhotos);
var f = window.frames["HtmlEditor"];
var aImage = f.document.getElementsByTagName("img");
for(var i=0; i<aImage.length;i++){
if (aImage[i].src == sPhotos){
aImage[i].style.width = "650px";
}
}
}
}发现不能用下面代码:onload='javascript:if(this.width > 650) this.width=650'
所以不要用这个.先谢谢了.
解决方案 »
- Ext Combobox问题,一直loading,一直加载中....
- extjs portal 怎么动态增加小模块呢?
- 帮忙解决一下这个问题
- 如何实现压缩图片后上传到服务器?
- 请教如何点击一个连接后,马上使其失效
- iframe如何提交到主页面
- JS获取指定范围的元素
- 关于在下拉框select中disabled的应用,求救!~~~~
- 谁能帮我找到这个网页中播放文件的Url。
- 我想修改class为TR的<tr>对象中的所有<td>对象的样式,能不能页通过添加CSS实现呢?
- 一个js文件中的方法调用另一个js文件中的另一个方法,FF下错误 is not defined
- 刚开始学 JS 求一个软件编写JS
if ((sPhotos!=null) && (sPhotos!="http://")){//如果sPhotos不等于空并且不等于http://
format("InsertImage", sPhotos);//调用format()函数
var f = window.frames["HtmlEditor"];//定义iframe对象
var aImage = f.document.getElementsByTagName("img");//定义iframe对象内的所有图片对象,返回的aImage应该是所有图片对象集合而成的一个数组
for(var i=0; i<aImage.length;i++){//循环
if (aImage[i].src == sPhotos){//如果(假设i=0)aImage中的第一个对象的src值等于sPhotos的值
aImage[i].style.width = "650px";//就设置它的宽度为650px
}
}
}
}ps:onload='javascript:if(this.width > 650) this.width=650'当然不对了,this是一个对象,width是一个css属性,应该这样this.style.width
我说的是在不用
var sPhotos=document.getElementById('imagess').value;
if ((sPhotos!=null) && (sPhotos!="http://")){
format("InsertImage", sPhotos);
var f = window.frames["HtmlEditor"];
var aImage = f.document.getElementsByTagName("img");
for(var i=0; i<aImage.length;i++){
if (aImage[i].src == sPhotos){
aImage[i].style.width = "650px";
}
}
}
}
的时候都不能直接用
onload='javascript:if(this.width > 650) this.width=650'