Javascript

JS判断当前DOM树是否加载完毕

/***@functionMonitorwhetherthedocumenttreeisloaded.*@paramfn*/functiondomReady(fn){if(document.addEventListener){//标准浏览器document.addEventListener('DOMContentLoa...

JS Cookie相关操作

functionsetCookie(cookieName,cookieValue,expires){//设置CookiefunctiongetCookieName(cookieName){//获取并返回与cookieName同名的cookie名称,允许大小写不同,如果不存在这样的cookie,就返回cookieName...
代码星球·2020-04-10

被引用的外部JS存在window.onload时,判断当前页面是否已存在window.onload,并进行相应处理

如果页面a.html引用了b.js,b.js里的方法需要在页面资源加载完成后执行,即在window.onload里执行;这时如果a.html里使用了window.onload方法,b.js就不能重复调用这个方法了,因为window.onload不能同时使用多个,否则后者会覆盖前者。可以用如下方法解决这个问题,即当a.h...

JS格式化时间(支持小程序,兼容IOS)

constREGEX=/(d{4})-(d{2})-(d{2})T(d{2}):(d{2}):(d{2})//***@functionformattime*@paramval,format*@return{string}*@example*<template>*<div>*<span>...

NodeJS + PhantomJS 前端自动化资源监控

前言:最近做前端资源监控,看了很多例子,没有达到想要的效果。首先的槽点是PhantomJS的官方文档,真鸡肋,其次是网上的例子,多数是介绍PhantomJS的用法,而并没有介绍怎么完整的去实现,跟官方文档好像也没啥区别......一、实现了什么?   本文只做一个简单的例子,获取网址加载时...

JS让任意图片垂直水平居中且页面不滚动

 说一下以前遇到的一个问题:    假设有一张小图,要实现点击查看大图的功能,而这个图的宽高可能会超过浏览器的宽高,这时候我们通过JS来改变图片的宽高,从而实现图片在浏览器居中显示且不滚屏。方法如下:    首先你要给小图添加一个...

Js跑马灯效果 && 在Vue中使用

DEMO:<!DOCTYPEhtml><html><head>  <title>滚动播报</title>  <metacharset="UTF-8">  <style>    .content{      height:60px;   ...

JS获取当前时间及时间戳相互转换

1.获取当前时间的 时间戳  Date.parse(newDate())  结果:14863475620002.获取当前 时间  newDate()  结果:MonFeb06201710:19:42GMT+0800(CST)3.将时间戳转换成时间  newDate(1486347562000)  结...

ajax循环读取json多维数组

test.json:{  "one":[      {        "name":"黑默丁格",        "car":"鲁LLL608",        "mobil":"15666666666",        "mount":"1",        "time":"2016-07-13",        "...

AngularJS的简单使用

官网下载:AngularJS路由视图需要:Angular-Route.js基于zepto的轻量级的JavaScriptUI库: App.js 用于开发跨平台的移动Web应用<!DOCTYPEhtml><htmlng-app='mainApp'><head><...
代码星球·2020-04-10

JQuery简单标签页实现

<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metahttp-equiv="X-UA-COMPATIBLE"content="IE=edge"><style>.choose{ma...
代码星球·2020-04-10

js根据不同浏览器(分辨率)调用不同css

根据不同浏览器:<scripttype="text/javascript">varversion=navigator.userAgent;if(version.indexOf("MSIE")>1){document.write("<linkhref='ie.css'rel='stylesheet...

JS判断IE版本并在页面显示内容

<scripttype="text/javascript">varisIE=function(ver){varb=document.createElement('b')b.innerHTML='<!--[ifIE'+ver+']><i></i><![endif]--...

bootstrap垂直下拉菜单默认展开

HTML:<divclass="col-md-3">  <navclass="navbar">    <divclass="container-fluid">      <divclass="navbar-headercommon-border-bottomcommon-bor...

JS返回上一页

 <button onclick="javascript:history.go(-1);">返回上一页</button> <button onclick="javascript:history.back(-1);">返回上一页</butt...
代码星球·2020-04-10