日常テクニックまとめ


 :            ,        ,     ,    。

1、  iframe:

     iframe   allowTransparency="true"     ,          body background     transparent

2、             :

   align="absmiddle"     ,          border=0                      

3、             cursor:hand,  FF   ,    cursor:pointer;

4、         :

        onkeyup="this.value = this.value.replace(/[^\d]/ig, '');" 

5、    a js             :

         ,  click here          (  ),         。      click here  click here

6、 innerHTML       html       div          

                     ,            html        。 ie               ,            。            textarea    ,        textarea   。  innerHTML       ,            html  ,    div         ,          。  textarea      csdn   ,            。

7、         html  :document.selection.createRange() .text .htmlText

8、 //        
function saveText(title, content, other) {
try{
var clip_data = clipboardData.getData('text');
if(clip_data.indexOf("#oLdDaTa&!!") != -1)
clipboardData.setData('text',clip_data.substring(clip_data.indexOf("#oLdDaTa&!!")+ 11, clip_data.length));
var str = "#bBsTiTlE&!!" + title + "#bBsCoNtEnT&!!" + content + "#bBsOtHeR&!!" + other + "#oLdDaTa&!!" + clipboardData.getData('text');
clipboardData.setData('text',str);
}catch(e){}
}
//      
function resetText(str) {
if(getIEVersonNumber() >= 7){
var autoSave = document.getElementById("auto_save");
autoSave.checked = "";
}
var tIndex = str.indexOf("#bBsTiTlE&!!");
if(tIndex == -1)
return;
var cIndex = str.indexOf("#bBsCoNtEnT&!!");
var oIndex = str.indexOf("#bBsOtHeR&!!");
var oldIndex = str.indexOf("#oLdDaTa&!!");
var title = document.getElementById("post_title");
if(typeof(title) == "undefined" || title == null)
return;
var content = document.PostForm[textName];

title.value = str.substring(12, cIndex);
content.value = removeFmt(str.substring(cIndex + 14, oIndex));
str = str.substring(oIndex + 12, oldIndex);
try {
if(str.substring(1, 2) == "1") {
document.getElementById("post.original").checked = "checked";
}
}catch (e) {}
if(str.substring(0, 1) == "1") {
document.PostForm[abname][0].checked = "checked";
} 
if(str.substring(2, 3) == "1") {
document.PostForm[nttname][1].checked = "checked";
}

}

//id textarea id,value       
function insertIntoText(target, value, bolReplace){
var ta = target;

if (document.selection) { //For IE
if (ta.currPos){
if(bolReplace){
ta.currPos.text=value;
}
else{
ta.currPos.text+=value;
}
}
else{
ta.value+=value;
}
}
else{ //For Firefox
var startPos = ta.selectionStart;
var endPos = ta.selectionEnd;

if(bolReplace)
ta.value = ta.value.substring(0, startPos) + value + ta.value.substring(endPos, ta.value.length);
else
ta.value = ta.value.substring(0, startPos) + value + ta.value.substring(startPos, ta.value.length);
}
}


9、          :onfocus="this.blur();"

10、    

function BwlDrag() {
 
 this.root    =  null;
 this.onDragStart  =  null;
 this.onDragEnd   =  null;
 this.onDrag   =  null;
 this.oldEvents  =  new Array();
 //o is the part that drag on, and oRoot is the main object
 this.init = function(o, oRoot) {
  this.root = oRoot && oRoot != null ? oRoot : o ;
  
  this.onDragStart  =  new Function();
  this.onDragEnd   =  new Function();
  this.onDrag   =  new Function();
  var caller    =  this;
  this.root.style.cssText  =  "background:#fff000;position:relative;left:0px;top:0px;z-index:100;";
  o.onmousedown = function(ev) {
   var eSrc = window.event? window.event.srcElement : ev.target;
   /*if(eSrc&&(eSrc.onclick||eSrc.nodeName.toLowerCase()!='tr')){
    return;
   }*/
   caller.start(ev);return false;
  }
  o.onmousemove = null;
 }

 this.start = function(ev) {
  ev=(window.event)?window.event:ev;
  var y = parseInt(this.root.style.top);
  var x = parseInt(this.root.style.left);

  this.onDragStart(x, y);
  this.lastMouseX = ev.clientX;
  this.lastMouseY = ev.clientY;
  
  var caller    =  this;
  this.oldEvents.push(document.onmousemove);
  this.oldEvents.push(document.onmouseup);
  
  if(this.root.setCapture) {
   this.root.setCapture(false);
  }
  document.onmousemove = function(ev){caller.drag(ev);return false;};
  document.onmouseup  = function(ev){caller.end(ev);return false;};
  return false;  
 }
 
 this.drag = function(ev) {
  ev=(window.event)?window.event:ev;
  var ey   =  ev.clientY;
  var ex   =  ev.clientX;
  var y    =  parseInt(this.root.style.top);
  var x    =  parseInt(this.root.style.left);
  var nx    = x + ex - this.lastMouseX;
  var ny   = y + ey - this.lastMouseY;
  
  this.root.style.left =  nx + "px";
  this.root.style.top  =  ny + "px";
  //this.root.style.cssText  =  "background:#fff000;position:relative;left:" + nx + "px;top:" + ny + "px;z-index:100;";
  this.lastMouseX =  ex;
  this.lastMouseY =  ey;  
  
  this.onDrag(nx, ny);
 }
 
 this.end = function(ev) {
  document.onmouseup   = this.oldEvents.pop();
  document.onmousemove  = this.oldEvents.pop();
  if(this.root.releaseCapture){
   this.root.releaseCapture();
  }
  this.onDragEnd(parseInt(this.root.style.left),parseInt(this.root.style.top));
  this.root.style.cssText  =  "background:#fff000;position:relative;left:" + this.root.style.left + "px;top:" + this.root.style.top + "px;z-index:100;";
 }
}