这是一篇测试文章abc
Author Archives: FoxLing
TextArea光标位置插入文字
需要实现:在光标位置处插入文字,以及获取焦点后光标位置处于文字末尾。
以前一直没有做过,今天了解了一下后实现并记录在此。
各浏览器TextArea获得焦点后的光标位置情况:
textarea.focus()
FireFox: 所有文字结束处
IE: 文字开头
Opera: 文字开头
Chrome: 文字开头
Safari: 文字开头
IE支持document.selection
Firefox,Chrome,Safari以及Opera都有selectionStart和selectionEnd属性
针对浏览器的特性进行判断并实现,代码如下:
function insertText(obj,str) {
obj.focus();
if (document.selection) {
var sel = document.selection.createRange();
sel.text = str;
} else if (typeof obj.selectionStart == ‘number’ && typeof obj.selectionEnd == ‘number’) {
var startPos = obj.selectionStart,
endPos = obj.selectionEnd,
cursorPos = startPos,
tmpStr = obj.value;
obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);
cursorPos += str.length;
obj.selectionStart = obj.selectionEnd = cursorPos;
} else {
obj.value += str;
}
}
function moveEnd(obj){
obj.focus();
var [...]
小技巧,跨域关闭iframe
示例
猛击打开iframe
解决方法
直接看代码吧:
function Dialog(){
this.panel = document.createElement(‘div’);
this.panel.id = ‘bmPanel’;
this.panel.style.position = ‘absolute’;
this.panel.style.right = ‘0px’;
this.panel.style.right = this.scrollTop() + ‘px’;
this.panel.style.zIndex = 100000;
this.panel.style.margin = ‘10px’;
this.panel.style.width = ‘200px’;
this.panel.style.height = ‘200px’;
this.panel.style.border = ‘5px solid #CCC’;
this.panel.innerHTML = ‘<iframe id=”bmIframe” ‘
+ ‘token=”1″ onload=”c = this.getAttribute(\’token\’); if (c==3) {this.parentNode.parentNode.removeChild(this.parentNode)} this.setAttribute(\’token\’,++c);”‘
+ ‘name=”bmIframe” src=”main.html” scrolling=”no” frameborder=”0″ style=”width:100%; height:100%; ‘
+ ‘border:1px; padding:0px; margin:0px”></iframe>’;
}
Dialog.prototype.show = function(){
document.body.appendChild(this.panel);
}
Dialog.prototype.scrollTop = function (){
return document.documentElement && [...]
Flash通过FlashVars接收外部参数
…
<param name=”FlashVars” value=”tag=as3″/>
<embed flashvars=”tag=as3″/>
…
AS项目,或者Flash里:
stage.loaderInfo.parameters.tag
Flex3项目:
Application.application.parameters.tag
Flex4项目:
FlexGlobals.topLevelApplication.parameters.tag
备忘.
查看火兔照片的小玩意,暂且叫PictureLife吧。
这两天突然好玩做了这么个玩意,输入火兔网的帐号即可浏览该用户的所有照片。
地址:
http://app.foxling.cn/picturelife/
功能:
鼠标拖动:左右滑动,向左滑动时,自动加载更多的照片(前提是还有更多照片…)
鼠标点击空白区域:缩放到合适大小
鼠标滚轮:放大,缩小显示区域
鼠标点击单张小图:加载该大图,并且放大到原始尺寸。
预览图:
后续:
仓促弄出来玩玩,有待继续改进。









