Dev
搜索

Dev

js中的this关键字详解
发表于2016-01-04|js
this是Javascript语言的一个关键字。它代表函数运行时,自动生成的一个内部对象,只能在函数内部使用 随着函数使用场合的不同,this的值会发生变化。但是有一个总的原则,那就是this指的是,调用函数的那个对象。 情况一:纯粹的函数调用 这是函数的最通常用法,属于全局性调用,因此this就代表全局对象Global。 function test(){ this.x = 1; alert(this.x); } test(); // 1 为了证明this就是全局对象,我对代码做一些改变: var x = 1; function test(){ alert(this.x); } test(); // 1 运行结果还是1。再变一下: var x = 1; function test(){ this.x = 0; } test(); alert(x); //0 情况二:作为对象方法的调用 函数还可以作为某个对象的方法调用,这时this就指这个上级对象。 function test(){...
JS的构造函数
发表于2016-01-04|js
原文地址:http://www.cnblogs.com/jikey/archive/2011/05/13/2045005.html //构造函数//使自己的对象多次复制,同时实例根据设置的访问等级可以访问其内部的属性和方法//当对象被实例化后,构造函数会立即执行它所包含的任何代码function myObject(msg){//特权属性(公有属性)this.myMsg = msg; //只在被实例化后的实例中可调用this.address = ‘上海’; //私有属性var name = ‘豪情’;var age = 29;var that = this; //私有方法function sayName(){alert(that.name);}//特权方法(公有方法)//能被外部公开访问//这个方法每次实例化都要重新构造而prototy...
PHP获取文件大小
发表于2016-01-04|php
这两天做了个把图片转为base64传到服务器后,想限制图片大小, 可以用strlen测量传回来的字符串长度,基本上即为图片大小 bit 乘以1024即为byte 注意这里使用strlen而不是sizeof sizeof() 函数计算 数组中元素数目 或 对象中的 属性个数。    
js获取当前域名
发表于2015-12-31|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
发表于2015-12-30|php
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
发表于2015-12-30|js
[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延迟
发表于2015-12-30|js
原文地址:http://amazeui.org/1.x/javascript/fastclick/ FastClick.attach(document.body); 不应用 FastClick 的场景 如果 viewport meta 标签 中设置了 width=device-width, Android 上的 Chrome 32+ 会禁用 300ms 延时;
absolute 定位居中代码
发表于2015-12-29|html
有时候 margin: 0 auto 无法居中 使用如下代码 其中宽度margin-left是宽度width除以二,就是先把左边界放到中间,然后移动到中间位置 left: 50%;margin-left: -190px;
HTML5 canvas drawImage() 方法
发表于2015-12-29|js
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() 方法
发表于2015-12-29|html
getContext() 方法返回一个用于在画布上绘图的环境。 语法 Canvas.getContext(contextID) 参数 参数 contextID 指定了您想要在画布上绘制的类型。当前唯一的合法值是 "2d",它指定了二维绘图,并且导致这个方法返回一个环境对象,该对象导出一个二维绘图 API。 提示:在未来,如果 <canvas> 标签扩展到支持 3D 绘图,getContext() 方法可能允许传递一个 "3d" 字符串参数。
1…697071…102
avatar
developer
AI相伴的开发者博客
文章
1017
标签
717
分类
33
Follow Me
公告
This is my Blog
最新文章
flutter getx使用记录2026-03-01
统计代码行数2026-02-27
php easywechat 6.x 微信支付 手动解密2026-02-25
php 反引号 执行shell脚本2026-02-25
mysql使用记录2026-02-19
分类
  • apicloud3
  • bootstrap8
  • cocos2d-js5
  • createjs17
  • day45
  • docker16
  • egret14
  • flash2x2
标签
接口 $wpdb js动画 微信分享定制注意事项 类型转换 issuer python环境 specified 删除失败 unable 会展行业 并携带cookie __call 手机抓包 汉字说明 读取 api go 备案 serverless 编译 协程 ts 转发 tp5 nfs 开发 查看 自建vpn Supervisor user 乱码 file event vscode Post Formats Anaconda 笔试题 display family
归档
  • 三月 2026 1
  • 二月 2026 5
  • 一月 2026 3
  • 十二月 2025 5
  • 十一月 2025 2
  • 十月 2025 5
  • 九月 2025 5
  • 八月 2025 2
网站信息
文章数目 :
1017
最后更新时间 :
© 2025 - 2026 By developer框架 Hexo 8.1.1|主题 Butterfly 5.5.4
搜索
数据加载中