Giter Club home page Giter Club logo

js-note's Introduction

Javascript高级程序设计学习笔记

1.富文本编辑

1.本质是在页面中嵌入iframe,设置designMode属性。designMode有两个值:on 和off
//跨浏览器事件处理程序
var EventUtil={
	addHandler:function(element,type,handler){
		if(element.addEventListener){
			element.addEventListener(type,handler,false);
		}else if(element.attachEvent){
			element.attachEvent('on'+type,hander);
		}else{
			element["on"+type] = handler;
		}
	},
	removeHandler:function(element,type,handler){
		if(element.removeEventListener){
			element.removeEventListener(type,handler,false)
		}else if(element.detachEvent){
			element.detachEvent("on"+type,handler);
		}else{
			element["on"+type] = handler;
		}
	}
};
2.另一个方法是使用属性:contenteditable
    <div id="aa" contenteditable></div>
3.操作富文本
document.execCommand----->包含三个参数:执行命令的名称,布尔值,执行命令必须的一个值(不需要,传入null)
document.execCommand('italic',false,null);
4.富文本选区
getSelection()//获取选区文本
anchorNode :选区起点所在节点

15章 canvas

  • 0.先判断getContext()是否存在
  • 1.toDataURL()方法,可以导出在canvas元素上绘制的图像
var draw=document.getElementById("drawing");
if(draw.getContext){
    //取得图像的数据URI
    var imgURI = draw.toDataURL("image/png");
   
    //显示图像
    var image = document.createElement('img');
    image.src=imgURI;
    document.body.appendChild(image);
}

2.绘制矩形

fillRect()、strokeRect()、clearRect()

fillRect(x,y,width,height);
arc()

第6章 HTML5

1.跨文档消息传递 :postMessage

js-note's People

Contributors

lizitang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.