'use strict';
//父类
class Student2{
  constructor(name){
    this.name = name || 'tom';
  }
  hello(){
    console.log('hello '+ this.name + '!');
  }
}
var xiao = new Student2("jack");
xiao.hello(); //子类继承父类
class PrimaryStudent2 extends Student2{
  constructor(name,grade){
    super(name); // 记得用super调用父类的构造方法!
    console.log(this);
    this.grade = grade;
    this.name = name;
  }
  mygrade(){
    console.log(this.name +' at grade '+ this.grade);
  }
}
var primary = new PrimaryStudent2('jack' ,'2');
primary.mygrade();
primary.hello();//调用父类的方法
 navigator 对象表示浏览器的信息,最常用的属性包括:

 navigator.appName:浏览器名称;
navigator.appVersion:浏览器版本;
navigator.language:浏览器设置的语言;
navigator.platform:操作系统类型;
navigator.userAgent:浏览器设定的User-Agent字符串。
   location http://www.example.com:8080/path/index.html?a=1&b=2#TOP
location.protocol; // 'http'
location.host; // 'www.example.com'
location.port; // '8080'
location.pathname; // '/path/index.html'
location.search; // '?a=1&b=2'
location.hash; // 'TOP'
要加载一个新页面,可以调用location.assign()。如果要重新加载当前页面,调用location.reload()方法非常方便。 if (confirm('重新加载当前页' + location.href + '?')) {
  location.reload();
} else {
  location.assign('/discuss'); // 设置一个新的URL地址
}
图片上传并显示
var fileInput = document.getElementById('test-image-file'),
info = document.getElementById('test-file-info'),
preview = document.getElementById('test-image-preview');
// 监听change事件:
fileInput.addEventListener('change', function () {
// 清除背景图片:
preview.style.backgroundImage = '';
// 检查文件是否选择:
if (!fileInput.value) {
info.innerHTML = '没有选择文件';
return;
}
// 获取File引用:
var file = fileInput.files[0];
// 获取File信息:
info.innerHTML = '文件: ' + file.name + '<br>' +
'大小: ' + file.size + '<br>' +
'修改: ' + file.lastModifiedDate;
if (file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
alert('不是有效的图片文件!');
return;
}
// 读取文件:
var reader = new FileReader();
reader.onload = function(e) {
var
data = e.target.result; // 'data:image/jpeg;base64,/9j/4AAQSk...(base64编码)...'
preview.style.backgroundImage = 'url(' + data + ')';
};
// 以DataURL的形式读取文件:
reader.readAsDataURL(file);
});

---恢复内容结束---

最新文章

  1. 一个简单的统计图像主颜色的算法(C#源代码)
  2. vb.net中常用键值
  3. 无法找到脚本引擎Jscript解决
  4. oralce11g 注冊表卸载20140810
  5. js后缀判断
  6. Hadoop运行中遇到的错误调试
  7. Javascript的精华
  8. Uva 12436 Rip Van Winkle&amp;#39;s Code
  9. iOS 如何优化 App 的启动时间
  10. 使用Dreamweaver正则表达式替换href中的内容
  11. 自定义view实现阻尼效果的加载动画
  12. spring cloud 容错之zuul回退和Zuul过滤器
  13. mysql基础常用命令
  14. ACM-ICPC 2018 沈阳赛区网络预赛 J Ka Chang
  15. JVM 自带性能监测调优工具 (jstack、jstat)及 JVM GC 调优
  16. POJ 2538
  17. linux系统挂载ISO文件
  18. Hashtable之Properties
  19. Problem C: 查找最大元素
  20. MySql 基础 基本使用方法

热门文章

  1. 调用jdbc已经写成的方法----jdbc工具类抽取方式三
  2. notepad++常用操作梳理
  3. XorPay 个人支付平台增加 个人支付宝支付接口
  4. mysql.sock文件丢失被删除解决方法
  5. Windows开发经验 - WinDbg
  6. Q221 最大正方形
  7. HLS:OpenCV和RTL代码转换关系
  8. 二、利用继承修改OPENERP 的一个模块
  9. anyncTask的3个参数(从源码可以发现其中使用了ThreadPoolExcuter线程池)
  10. PHP之string之trim()函数使用