随笔分类 - JavaScript
摘要:###XSS 跨站脚本攻击(Cross Site Scripting),为了不和层叠样式表 CSS 混淆,故将跨站脚本攻击缩写为 XSS。恶意攻击者往 Web 页面里插入恶意 Script 代码,当用户浏览该页之时,嵌入其中 Web 里面的 Script 代码会被执行,从而达到恶意攻击用户的目的。
阅读全文
摘要:#####1、IE8下面的png图片无法正常显示? 原因:打开调试面板,你会发现IE8浏览器把PNG格式的img解析成了span标签,导致图片无法显示。 解决方案:在央视里面对span设置宽高和display:inline-block; #####2、rgba不支持IE8? 解决方案:可以用 opa
阅读全文
摘要:div跟随鼠标移动 <body style="width: 2000px;height: 1000px;"> <div id="box1" style="width: 100px;height: 100px;background-color: red;position: absolute;"></d
阅读全文
摘要:<button>动画</button> <div class="box" style="left:0px;position: absolute; width: 100px;height: 100px;background-color: pink;"></div> <script> var btn =
阅读全文
摘要:<style> input{ display: block; } </style> <body> <ul><input type="text"><input type="text"><input type="text"><input type="text"></ul> </body> var inp
阅读全文
摘要:<body> <a href="">点我打开一个新的页面</a> <a href="">点我关闭本页面</a> </body> var a1 = document.getElementsByTagName('a')[0] var a2 = document.getElementsByTagName(
阅读全文
摘要:<style> .box { width: 300px; height: 200px; padding-top: 100px; background-color: pink; margin: 100px; text-align: center; font: 18px/30px '宋体'; curso
阅读全文
摘要:<body> <button> 运动200 </button> <button>运动400</button> <div style="width: 100px;height: 100px;background-color: pink;position: absolute;"></div> </bod
阅读全文
摘要:<body> <table style="width:600px;" border="1" cellspacing="0" cellpadding="0"> <tbody id="tbody"> <tr> <td>序号1</td> <td>张三</td> <td>28</td> <td>保定</td
阅读全文
摘要:<style> *{ margin: 0; padding: 0; } .content{ width: 100%; height: 100%; overflow-y: scroll; } #box{ width: 100%; height: 3000px; } #btn{ width: 150px
阅读全文
摘要:<body> <ul id="parent-list"> <li><a href="javascript:;" class="my_link">超链接一</a></li> <li><a href="javascript:;" class="my_link">超链接二</a></li> <li><a
阅读全文
摘要:原型对象 原型的引入 function Person(name, age, gender) { this.name = name; this.age = age; this.gender = gender; //向对象中添加一个方法 this.sayName = function () { cons
阅读全文
摘要:创建自定义对象的几种方法 方式一:对象字面量 对象的字面量就是一个。里面的属性和方法均是键值对: 键:相当于属性名。 值:相当于属性值,可以是任意类型的值(数字类型、字符串类型、布尔类型,函数类型等)。 使用对象字面量来创建一个对象,非常简洁,举例如下:: var obj = {}; 使用对象字面量
阅读全文
摘要:前言 JS 专门为我们提供了一些方法来改变函数内部的 this 指向。常见的方法有 call()、apply()、bind() 方法。 call() 方法 call() 方法的作用 call() 方法的作用:可以调用一个函数,与此同时,它还可以改变这个函数内部的 this 指向。 call() 方法
阅读全文
摘要:闭包的引入 我们知道,变量根据作用域的不同分为两种:全局变量和局部变量。 函数内部可以访问全局变量和局部变量。 函数外部只能访问全局变量,不能访问局部变量。 当函数执行完毕,本作用域内的局部变量会销毁。 比如下面这样的代码: function foo() { let a = 1; } foo();
阅读全文
摘要:数组的方法清单 数组的类型相关 方法 描述 备注 Array.isArray() 判断是否为数组 toString() 将数组转换为字符串 Array.from(arrayLike) 将伪数组转化为真数组 Array.of(value1, value2, value3) 创建数组:将一系列值转换成数
阅读全文
摘要:作用域、变量提升的知识点,面试时会经常遇到。 作用域(Scope)的概念 概念:通俗来讲,作用域是一个变量或函数的作用范围。作用域在函数定义时,就已经确定了。 目的:为了提高程序的可靠性,同时减少命名冲突。 作用域的分类 在 JS 中,一共有两种作用域:(ES6 之前) 全局作用域:作用于整个 sc
阅读全文
摘要:` Document #big { width: 300px; height: 300px; background-color: aqua; } #small { width: 100px; height: 100px; background-color: brown; } </style> a `
阅读全文

浙公网安备 33010602011771号