Lotus教程、Java教程、Java虚拟机、Java软件综合开发社区

Lotus、Domino、Java、C#、Web、数据库综合开发教程、资料社区

Archive for the ‘Javascript’ Category

为ckeditor编辑器添加行距功能

Published by admin on 05月 6, 2012

在选用ckeditor编辑器是,感觉缺少行距功能而遗憾,网上搜索资料零散,却很少有系统的例子,为此收集并整理,提供例子下载。为ckeditor编辑器添加行距功能,添加之后的效果如下:
Read the rest of this entry »

CKeditor加入中文字体

Published by admin on 05月 6, 2012

CKeditor确实非常好,但是编辑时,字体选择里面没有中文字体。可以按如下方法添加:

打开CKeditor目录里的config.js,在

CKEDITOR.editorConfig = function( config )
{
};
里添加如下代码:

Read the rest of this entry »

[html5 canvas] 实现转换图片为灰度模式

Published by admin on 01月 29, 2012

需要把之前用jq来做的图片改”黑白”转成dojo实现

思路

么有思路..囧. 网上找到解决办法. 大概是如下这样. 因为需求说明了, 针对非IE浏览器.

  1. 在canvas中绘制出目标图像.
  2. 获取图像的所有像素点, getImageData().
  3. 遍历所有像素, 将RGB转换为灰度值(灰度值对应的RGB三个值相等. 即R=G=B=灰度值)
  4. 将处理之后的图片数据重新载入原图片, putImageData()

这里涉及到一个灰度值的计算公式, 网上找了些, 老版本的解决方案是grayscale= (R+G+B)/3, 然后将grayout赋值给RGB, 这个不够精确, 新版本为grayscale = R*0.3+G*0.59+B*0.11.

Read the rest of this entry »

超链接样式和水平线样式

Published by admin on 11月 6, 2011

超链接:

a:link{ color :#00688B;text-decoration:none;font-size: small}//未
a:hover{ color :#000000;text-decoration:underline}
a:active{ color :Gray ;text-decoration:underline}
a:visited{ color :#00688B;text-decoration:none;font-size: small }//过

水平线:

<hr size=”1″ style=”border-style: dotted dotted none; border-bottom: medium none;”>

1、普通分隔线:<hr>
——————————————————————————–
2、分隔线宽度属性:<hr width=50%> 或者 <hr width=250> (宽度为实际点数或百分比)
——————————————————————————–
3、分隔线位置属性:<hr align=right width=50%> (位置分为 Left、Center、Right 三种)

Read the rest of this entry »

css 背景图片平铺技巧

Published by admin on 11月 6, 2011

使用css来设置背景图片同传统的做法一样简单,但相对于传统控制方式,css提供了更多的可控选项,我们先来看看最基本的设置图片的方法。

xhtml代码:

<div id=”content”>
</div>

css代码:
#content {
border:1px solid #000fff;
height:500px;
background-image:url(images/bg.GIF);
}

网页中id为content的元素被我们设置了使用images文件夹下的bg.GIF作为背景,与传统表格式布局中的设置并无差别,在默认状态下,背景同样以平铺的方式出现在元素之中。然而使用css来控制背景当然不可能如此简单,实际上css为我们提供了更多用于控制背景的属性,包含可以控制元素是否需要平铺。改进后的代码:

Read the rest of this entry »

title等 显示提示信息时 换行

Published by admin on 10月 23, 2011

简单方法: 试了 确实好使 目前不是原网页 所以效果上看不出来

当使用img的alt或者a的title属性来显示文字提示窗口的时候是不能使用HTML标签来进行排版的。不过有时候做程序的时候需要在鼠标放到图片或者链接上的时候显示一些信息,这个时候如果不能用HTML也就算了,可是连换行也没有,实在不容易让浏览者“幸福”。

呵呵,这个时候可以使用

Read the rest of this entry »

Javascript禁止网页复制粘贴效果,或者复制时自动添加来源信息

Published by admin on 10月 12, 2011

一、禁止复制

使用方法:在oncopy事件中return false

oncopy=”return false;”

1、禁止复制网页内容

<body oncopy=”return false;”>

2、禁止复制元素内容
Read the rest of this entry »

常见的有关检查数据的JS代码

Published by admin on 09月 24, 2011

这些JS代码都是一些在表单提交时经常用到的代码,大部分代码也都是用正则表达式写的!

//去左空格;
function ltrim(s){
return s.replace( /^\s*/, “”);
}
//去右空格;
function rtrim(s){
return s.replace( /\s*$/, “”);
}
//左右空格;
function trim(s){
return rtrim(ltrim(s));
}

Read the rest of this entry »

js通过window.open打开子窗口,子窗口给父窗口 赋值

Published by admin on 07月 16, 2011

父窗口代码:

<input id=”txtOpener” type=”text” />

<input id=”Button1″ type=”button” value=”打开窗口” onclick=”window.open(’pagename.html’,null,’width=800,height=500′);” />

子窗口代码:

Read the rest of this entry »

showModalDialog和showModelessDialog使用心得

Published by admin on 07月 16, 2011

一、showModalDialog和showModelessDialog有什么不同?
showModalDialog:被打开后就会始终保持输入焦点。除非对话框被关闭,否则用户无法切换到主窗口。类似alert的运行效果。
showModelessDialog:被打开后,用户可以随机切换输入焦点。对主窗口没有任何影响(最多是被挡住一下而以。:P)

二、怎样才让在showModalDialog和showModelessDialog的超连接不弹出新窗口?
在被打开的网页里加上 <base target= “_self “> 就可以了。这句话一般是放在 <html> 和 <body> 之间的。

三、怎样才刷新showModalDialog和showModelessDialog里的内容?
在showModalDialog和showModelessDialog里是不能按F5刷新的,又不能弹出菜单。这个只能依靠javascript了,以下是相关代码:

Read the rest of this entry »