爱玺玺

爱玺玺的生活日记本。wx:lb87626

DOM和BOM

DOM文档对象模型 基于document

BOM浏览器对象模型 基于浏览器browser

js事件阻止浏览器默认操作 例如阻止表单提交

return fasle;只对DOM1事件起作用。

evt.preventDefault();对一级二级都起作用。


js冒泡型和捕捉型使用stopPropagation阻止事件传递

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

  <meta http-equiv="Content-Type" content="text/html;charset=UT

js获取鼠标坐标

    var div=document.getElementsByTagName("div")[0];

    div.addEventListener("click",function(ev){

     var oEvent=ev||event;

     //相对页面可见区域坐标

     console.log(oEvent.clientX+" "+oEvent.clientY);

     //相对页面滚动区域坐标

     console.log(oEvent.pageX+" "+oEvent.pageY);

     //相对显示器坐标

     console.log(oEvent.screenX+" "+oEvent.screenY);

    });


js全局变量上级对象是window,可以通过window访问所有全局变量

js全局变量上级对象是window,可以通过window访问所有全局变量

html5访问历史记录完整版

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style>

html,body{width: 100%; overflow: hidden; height: 100%;}

aside{

js获取网址参数部分字符串window.location.search

//解析url地址打开页面

                  var url=window.location.search;

                  console.log(url);


js添加子元素不要用append因为ie不支持用appendChild()

js添加子元素不要用append因为ie不支持用appendChild()

oAside.appendChild(oLi);

html5点击侧边栏切换主区域内容也能使用浏览器前进后退功能历史按钮

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style>

html,body{width: 100%; overflow: hidden; height: 100%;}

aside{

html5点侧边栏切换主页面内容

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style>

html,body{width: 100%; overflow: hidden; height: 100%;}

aside{

Powered By Z-BlogPHP 1.4 Deeplue Build 150101

Copyright Your WebSite.Some Rights Reserved.

蜀ICP备11021721号-5