2013年08月12日

javascript继承机制

Filed under: JS » Node.js — cmpan @ 2013-08-12 19:56:04

1、构造函数继承

1
2
3
4
5
6
7
8
9
10
11
12
13
function Animal(){
    this.species = "动物";
}

function Cat(name, color){
    Animal.apply(this, arguments);
    this.name = name;
    this.color = color;
}

var cat1 = new Cat("大毛", "黄色");

console.log(cat1.species);  // 动物

(全文 …)

Views – 2977

2012年11月7日

jQuery轻松实现拖动效果

Filed under: JS — cmpan @ 2012-11-07 19:21:47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery轻松实现拖动</title>
<style type="text/css">
#drag { width:420px; height:360px; background:#DDD; cursor:move; position:absolute; left:100px; top:100px; border: 1px solid #666;}
h2 { background:#AAA; color:#fff; line-height:40px; margin:0; padding-left:10px;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
//案例开始
$(function(){
    $('#drag').mousedown(function(e) {
        var _x = e.pageX;
        var _y = e.pageY;
        this.setCapture && this.setCapture(); // 关键部位1
           
        $(this).mousemove(function(e) {
            var x    = e.pageX;
            var y    = e.pageY;
            var pos  = $(this).position();
            var left = (x - _x + pos.left) + 'px';
            var top  = (y - _y + pos.top) + 'px';
           
            _x = x;
            _y = y;
           
            $(this).css('left', left);
            $(this).css('top', top);
        })     
       
        $(this).mouseup(function(){
            $(this).unbind('mousemove');
            $(this)[0].releaseCapture(); // 关键部位2
        });
    });
});
//]]>
</script>
</head>

<body>
    <div id="drag">
        <h2>Drag me</h2>
        <div></div>
    </div>
</body>
</html>

Views – 1888

2012年09月21日

IE JS 调试

Filed under: JS » WEB — cmpan @ 2012-09-21 10:00:48

安装调试工具:
IE Developer Toolbar

http://www.my-debugbar.com/wiki/CompanionJS/HomePage

http://www.debugbar.com/download.php

Views – 1944

2011年11月27日

IE下类似firebug的调试工具DebugBar

Filed under: JS — cmpan @ 2011-11-27 04:59:34

下载地址:http://www.debugbar.com/download.php
该网站还提供ie下使用的仿firebug-lite的CompanionJS:http://www.my-debugbar.com/wiki/CompanionJS/HomePage
比较有名的IETester也是该站出品:http://www.my-debugbar.com/wiki/IETester/HomePage

Views – 2422

解决ie下JS提示“尚未实现 ”错误

Filed under: CSS » JS — cmpan @ 2011-11-27 04:43:48

鼠标经过链接的时候,总提示JS 1行、第xx个字符,错误信息是:“尚未实现 ”。从js入手调试了半天,解决不了问题。想到是不是css里的expression引起的,把链入的样式去掉,果真是。css的expression调用了ie不支持的方法引起js错误提示。IE这SB只知道第1行、第xx个字符出错了,不可信。

Views – 2373

2010年02月28日

页面内附件自动下载

Filed under: JS — 标签: — cmpan @ 2010-02-28 09:47:24

很多人问页面内怎样自动下载文件
其实是很简单的,只要在页面尾部加js

1
2
3
<script type='text/javascript'>
location="附件地址";
</script>

Views – 2097

2009年08月18日

SyntaxHighlighter 很不错的js版的代码高亮显示工具

Filed under: JS — 标签:, — cmpan @ 2009-08-18 14:01:36

SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript. To get an idea of what SyntaxHighlighter is capable of, have a look at the demo page.

The project was started in 2004 and since then has gained a lot of acceptance. Version 2.0 is the new page in history of the project representing a near complete rewrite, clean up, optimization, standard compliance and new features.

项目地址http://alexgorbatchev.com/wiki/SyntaxHighlighter

(全文 …)

Views – 2142

2009年08月13日

让FCKEditor 2.6.4.1 能插入 视频和音频

Filed under: JS » 未分类 — 标签:, — cmpan @ 2009-08-13 14:17:10
一、分别打开:editor/js/fckeditorcode_ie_1.js和/editor/js/fckeditorcode_gecko_1.js
找到程序代码 .swf
改成 .(swf|mov|qt|avi|wmv|asf|wma|mid|mp3|mpg|rm|ra|rmvb|ram)

二、打开/editor/dialog/fck_flash/fck_flash.js

1、增加程序代码

// DP 20090813
function WinPlayer(url){
    var r, re;
    re = /.(avi|wmv|asf|wma|mid|mp3|mpg)$/i;
    r = url.match(re);
    return r;
}

function RealPlayer(url){
    var r, re;
    re = /.(rm|ra|rmvb|ram)$/i;
    r = url.match(re);
    return r;
}

function QuickTime(url){
    var r, re;
    re = /.(mov|qt)$/i;
    r = url.match(re);
    return r;
}

function FlashPlayer(url){
    var r, re;
    re = /.swf$/i;
    r = url.match(re);
    return r;
}

2、替换程序代码
	SetAttribute( e, 'type'			, 'application/x-shockwave-flash' ) ;
	SetAttribute( e, 'pluginspage'	, 'http://www.macromedia.com/go/getflashplayer' ) ;
为

	if(WinPlayer(GetE('txtUrl').value)!=null){
		SetAttribute( e, 'type'		, 'application/x-mplayer2' ) ;
		SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
	}
	if(RealPlayer(GetE('txtUrl').value)!=null){
		SetAttribute( e, 'type'		, 'audio/x-pn-realaudio-plugin' ) ;
		SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
	}
	if(QuickTime(GetE('txtUrl').value)!=null){
		SetAttribute( e, 'type'		, 'video/quicktime' ) ;
		SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
	}
	if(FlashPlayer(GetE('txtUrl').value)!=null){
		SetAttribute( e, 'type'	, 'application/x-shockwave-flash' ) ;
		SetAttribute( e, 'scale', GetE('cmbScale').value ) ;
		SetAttribute( e, 'menu',  GetE('chkMenu').checked ? 'true' : 'false' );
		SetAttribute( e, 'play',  GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
		SetAttribute( e, 'pluginspage'	, 'http://www.macromedia.com/go/getflashplayer' ) ;
	}

替换程序代码
	SetAttribute( e, 'type'		, 'application/x-shockwave-flash' ) ;
为

	if(WinPlayer(GetE('txtUrl').value)!=null){
		SetAttribute( e, 'type'	, 'application/x-mplayer2' ) ;
	}
	if(RealPlayer(GetE('txtUrl').value)!=null){
		SetAttribute( e, 'type'	, 'audio/x-pn-realaudio-plugin' ) ;
	}
	if(QuickTime(GetE('txtUrl').value)!=null){
		SetAttribute( e, 'type'	, 'video/quicktime' ) ;
	}

	if(FlashPlayer(GetE('txtUrl').value)!=null){
		SetAttribute( e, 'type'	, 'application/x-shockwave-flash' ) ;
	} 

三、修改D:\yulans\web\js\fckeditor\editor\filemanager\connectors\php\config.php

$Config['AllowedExtensions']['Flash']	= array('swf','flv') ;

改成

$Config['AllowedExtensions']['Flash']	= array('swf','flv','mov','qt','avi','wmv','asf','wma','mid','mp3','mpg','rm','ra','rmvb','ram') ;

Views – 2807

Copyright © 2009 流水孟春 版权所有
Web技术,LAMP,Nginx,Web2.0,前端技术
Powered by WordPress & UI Designed by 流水孟春