alert

JS的作用域概念

廉价感情. 提交于 2020-01-18 02:08:14
作用域:什么样的空间去读和写 域:空间、范围、区域。。。  <script> 全局变量 全局函数 一个<script>就是一个域 作用:读、写 <script> alert(a); //结果是Undefined var a=1 </script> 为什么? <script> alert(a); //直接报错 a=1 </script> 为什么? 浏览器内部专门读取JS文件的程序:“JS解析器” 作用域="JS解析器"的工作方式 <script> alert(a); var a=1; function fn1(){ alert(2); } </script> 至少有两步: 1) "找一些东西": var function 参数; 上面那个代码预编译(预解析) :找到 var function;         var a=undefined (可以理解为没有逐行运行代码之前的所有的var都是提前赋值未定义,偷懒的机制)         fn1=funciton fn1(){alert(2)} (所有的函数,在正式运行代码之前,都是整个函数块)         把找到的var fn1放入一个仓库里 2)逐行解读代码:   表达式 (= + - * % / ++ --! 参数...):能够做一些改变的东西         上面代码 alert(a) 在仓库里面找到 var a

JS的数据类型

非 Y 不嫁゛ 提交于 2020-01-17 22:31:19
ECMAScript:标准、JS的核心 HTML标签类型:block、inline、inline-block、table...... JS中的数据类型:数字、字符串、布尔、函数、对象(obj、[数组]、{json}、null)、未定义 typeof 判断数据类型 数字类型 var i = 100; alert(typeof i); // number 字符串类型 var s = "miaov"; alert( typeof s ); // string alert( s.length ); // 5 (空格也算)字符串类型可以获取长度 alert( s.charAt(2) ); // a 根据子字符串的下标去获取你想要的字符串 布尔值:true false var b = true; alert( typeof b ); //boolean 函数 var fn = function (){ alert(1); }; fn(); // 1 function fn1(){ alert(2); } alert( fn1 ); // function fn1(){ alert(2); } fn1(); // 2 var obj = document; alert( typeof obj ); // object 物体、东西、对象 obj.abc = 123; // object

三个键盘事件的区别:

帅比萌擦擦* 提交于 2020-01-17 22:31:03
onkeyup: 这个事件在用户按下并放开任何字母数字键时发生。系统按钮(例如,箭头键和功能键)无法得到识别。 onkeydown: 这个事件在用户放开任何先前按下的键盘键时发生。 onkeypress : 这个事件在用户按下任何键盘键(包括系统按钮,如箭头键和功能键)时发生。 三者之间的执行顺序: 当按下回车时,焦点从文本框移到按钮上。如果把它换成“onkeypress”,焦点不会转移,也不会失去。但是如果换成“onkeyup”,则失去焦点,页面重新载入。 测试发现onkeydown 事件最先执行,其次是onkeypress,最后是onkeyup;onkeydown 和onkeypress会影响onkeyup的执行。三个事件同事在的话,都是alert的话,只会弹出2个alert,up事件的alert不会弹出。 三者之间的不同点: 三者在事件的响应上还有一点不同,就是onkeydown 、onkeypress事件响应的时候输入的字符并没有被系统接受,而响应onkeyup的时候,输入流已经被系统接受。由于onkeydown 比onkeypress先执行,再根据上面的例子可以知道,onkeydown 触发的时候输入流正要进入系统,也就是说onkeydown 事件一完,输入流就进入了系统,无法改变。所以通过onkeydown 事件可以改变用户是按了哪个键

How to create an alert box without using Tkinter?

五迷三道 提交于 2020-01-17 18:11:32
问题 I need to create a message box in python without using python Tkinter library so that I can use that before using exit() function this will display the message and answer as soon as user presses okay, user gets out of program. 回答1: Here's one way to do it with Windows' msg command. The code is based on @ErykSun's comment under the question Can't execute msg (and other) Windows commands via subprocess. import os import subprocess sysroot = os.environ['SystemRoot'] sysnative = (os.path.join

How to create an alert box without using Tkinter?

只愿长相守 提交于 2020-01-17 18:10:19
问题 I need to create a message box in python without using python Tkinter library so that I can use that before using exit() function this will display the message and answer as soon as user presses okay, user gets out of program. 回答1: Here's one way to do it with Windows' msg command. The code is based on @ErykSun's comment under the question Can't execute msg (and other) Windows commands via subprocess. import os import subprocess sysroot = os.environ['SystemRoot'] sysnative = (os.path.join

Alter page style because of screen inches

给你一囗甜甜゛ 提交于 2020-01-17 15:40:32
问题 I'm doing a program where every time a user enters the page, a message of 'Hello' appears for 2 seconds. I have set the message to appear in a position of ‘left: 75%’ and ‘top:0’ The problem is that I fixed that position when I was testing the style on a 25 '' screen but when I went to my laptop that is 14 '' the message has 'hidden' and I can only see part of it. Is there any way that the position of the posted message works for all the inches of the screens? How could I solve this? Can

XSS代码对不同浏览器的支持与特性(详细版含测试效果)-HTML5特性向量

有些话、适合烂在心里 提交于 2020-01-17 12:59:51
HTML5特性向量 通过formaction进行XSS-需要用户交互(1) 一个显示HTML5表单和formaction功能的向量,用于在实际表单之外进行表单劫持。 1 <form id="test"></form><button form="test" formaction="javascript:alert(1)">X</button> 适用浏览器与版本 测试效果 通过自动对焦自动执行焦点事件 此向量使用具有自动聚焦的输入元素来调用其自己的聚焦事件处理程序-无需用户交互 1 <input onfocus=write(1) autofocus> 适用浏览器与版本 测试效果 通过自动对焦竞赛 自动执行模糊事件 在这里,我们有两个HTML输入元素争夺焦点-一个正在执行JavaScript以失去焦点 1 <input onblur=write(1) autofocus><input autofocus> 适用浏览器与版本 测试效果 通过<VIDEO>poster属性执行JavaScript Opera 10.5+允许将发帖者属性与javascript:URI结合使用。 此错误已在Opera 11中修复。 1 <video poster=javascript:alert(1)//></video> 测试效果 无法测试 适用浏览器与版本 通过<BODY>onscroll

ES6的Symbol

南笙酒味 提交于 2020-01-17 03:57:22
let s = Symbol(); alert(typeof(s)); // Symbol函数可以接受一个字符串作为参数,表示对 Symbol 实例的描述,主要是为了在控制台显示,或者转为字符串时,比较容易区分。 let s1 = Symbol('foo'); let s2 = Symbol('bar'); // s1 // Symbol(foo) // s2 // Symbol(bar) alert(s1.toString()); // "Symbol(foo)" alert(s2.toString()); // "Symbol(bar)" // s1和s2是两个 Symbol 值。如果不加参数,它们在控制台的输出都是Symbol(),不利于区分。有了参数以后,就等于为它们加上了描述,输出的时候就能够分清,到底是哪一个值。 // Symbol函数的参数只是表示对当前 Symbol 值的描述,因此相同参数的Symbol函数的返回值是不相等的。 // 没有参数的情况 // let s1 = Symbol(); // let s2 = Symbol(); // s1 === s2 // false // // 有参数的情况 // let s1 = Symbol('foo'); // let s2 = Symbol('foo'); // s1 === s2 // false //

jQuery基础事件

馋奶兔 提交于 2020-01-16 12:21:15
<body> <input type="text" value="" /> <div style="width:100px; height:100px; background-color:#0E0"> <div style="width:50px; height:50px; background-color:blue"></div> </div> </body> </html> <script> $(document).ready(function(e) { //mouseover,mouseout //mouseenter,mouseleave 效果差不多,只不过enter和leave 对子元素无效,over和out 会触发子节点 $('input').keydown(function(e){ alert(e.keyCode); }) $('input').keypress(function(e){ alert(e.charCode); }) $('input').focus(function(){ alert('光标激活'); }) $('input').blur(function(){ alert('光标离开'); }) //focus和blur必须是当前元素才能激活,focusin和focusout可以使子元素激活 $('div').hover(function(){ $

vue中手机号,邮箱正则验证以及60s发送验证码

和自甴很熟 提交于 2020-01-16 10:28:07
今天写了一个简单的验证,本来前面用的组件,但是感觉写的组件在此项目不是很好用,由于用到的地方比较少,所以直接写在了页面中。页面展示如图 <div> <p class="fl"> <input name="phone" type="number" placeholder="手机号" v-model="phone"/> <button type="button" :disabled="disabled" @click="sendcode" class="btns">{{btntxt}}</button> </p> <p class="fl" style="margin-left: 20px;"> <input type="text" placeholder="验证码"/> </p> </div> <input type="button" value="查询" class="btns search" @click="query"/> 这里是 script 里的内容 export default { data: function () { return { disabled:false, time:0, btntxt:"获取验证码", formMess:{ email:this.email, phone:this.phone } } }, mounted: function () { },