PHP获取文件大小
这两天做了个把图片转为base64传到服务器后,想限制图片大小, 可以用strlen测量传回来的字符串长度,基本上即为图片大小 bit 乘以1024即为byte 注意这里使用strlen而不是sizeof sizeof() 函数计算 数组中元素数目 或 对象中的 属性个数。
js获取当前域名
<script language=”javascript”>//获取域名host = window.location.host;host2=document.domain; //获取页面完整地址url = window.location.href; document.write(“<br>host=”+host)document.write(“<br>host2=”+host2)document.write(“<br>url=”+url)</script>
php gd库 imagettftext
array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile ,string $text ) image An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(). size The font size. Depending on your version of GD, this should be specified as the pixel size (GD1) or point size (GD2). angle The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For e...
微信 drawImage
[pcsh lang=”js” tab_size=”4” message=”” hl_lines=”” provider=”manual”] function getimgbase64(file){ var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); canvas.width = canvaswidth; canvas.height = canvasheight; var x=$('#make-photo .theme').children('.photo').css('left').split('px')[0]; var img = new Image(); function tmpLoad() { x = x > 0 ? x : -x; ctx.drawImage(im...
禁用HTML5 300ms延迟
原文地址:http://amazeui.org/1.x/javascript/fastclick/ FastClick.attach(document.body); 不应用 FastClick 的场景 如果 viewport meta 标签 中设置了 width=device-width, Android 上的 Chrome 32+ 会禁用 300ms 延时;
absolute 定位居中代码
有时候 margin: 0 auto 无法居中 使用如下代码 其中宽度margin-left是宽度width除以二,就是先把左边界放到中间,然后移动到中间位置 left: 50%;margin-left: -190px;
HTML5 canvas drawImage() 方法
var context = c.getContext("2d"); JavaScript 语法 1 在画布上定位图像: context.drawImage(img,x,y); JavaScript 语法 2 在画布上定位图像,并规定图像的宽度和高度: context.drawImage(img,x,y,width,height); JavaScript 语法 3 剪切图像,并在画布上定位被剪切的部分: context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
HTML DOM getContext() 方法
getContext() 方法返回一个用于在画布上绘图的环境。 语法 Canvas.getContext(contextID) 参数 参数 contextID 指定了您想要在画布上绘制的类型。当前唯一的合法值是 "2d",它指定了二维绘图,并且导致这个方法返回一个环境对象,该对象导出一个二维绘图 API。 提示:在未来,如果 <canvas> 标签扩展到支持 3D 绘图,getContext() 方法可能允许传递一个 "3d" 字符串参数。
HTML5中类jQuery选择器querySelector的使用
原文地址http://www.cnblogs.com/Wayou/p/html5_web_api_queryselector.html HTML5向Web API新引入了document.querySelector以及document.querySelectorAll两个方法用来更方便地从DOM选取元素 用法 两个方法使用差不多的语法,都是接收一个字符串参数,这个参数需要是合法的CSS选择语法。 element = document.querySelector('selectors'); elementList = document.querySelectorAll('selectors'); 其中参数selectors 可以包含多个CSS选择器,用逗号隔开。 element = document.querySelector('selector1,selector2,...'); elementList = document.querySelectorAll('selector1,selector2,...'); 使用这两个方法无法查找带伪类状态的元素,比如querySe...
JS prototype 原型
1 原型法设计模式 在.Net中可以使用clone()来实现原型法 原型法的主要思想是,现在有1个类A,我想要创建一个类B,这个类是以A为原型的,并且能进行扩展。我们称B的原型为A。 2 javascript的方法可以分为三类: a 类方法 b 对象方法 c 原型方法 例子: function People(name) { this.name=name; //对象方法 this.Introduce=function(){ alert("My name is "+this.name); } } //类方法 People.Run=function(){ alert("I can run"); } //原型方法 People.prototype.IntroduceChinese=function(){ alert("我的名字是"+this.name); } //测试 var p1=new People(“Windking”); p1.Introduce(); People.Run(); p1.IntroduceChinese()...