This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
感觉cheet.js挺有意思的,制造页面彩蛋,随便写了一个 | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var keys = { | |
backspace: 8, | |
tab: 9, | |
enter: 13, | |
'return': 13, | |
shift: 16, | |
'⇧': 16, | |
control: 17, | |
ctrl: 17, | |
'⌃': 17, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<input type="text" name="" id="hello"> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob | |
var rhinoStorage = localStorage.getItem("rhino"), | |
rhino = document.getElementById("rhino"); | |
if (rhinoStorage) { | |
// Reuse existing Data URL from localStorage | |
rhino.setAttribute("src", rhinoStorage); | |
} | |
else { | |
// Create XHR, Blob and FileReader objects | |
var xhr = new XMLHttpRequest(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style> | |
[data-i18n="hello"]:before { | |
content: "Hello Maksim!"; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".overlayLink").bind("mouseenter mouseleave",function(e){ | |
/** the width and height of the current div **/ | |
var w = $(this).width(); | |
var h = $(this).height(); | |
/** calculate the x and y to get an angle to the center of the div from that x and y. **/ | |
/** gets the x value relative to the center of the DIV and "normalize" it **/ | |
var x = (e.pageX - this.offsetLeft - (w/2)) * ( w > h ? (h/w) : 1 ); | |
var y = (e.pageY - this.offsetTop - (h/2)) * ( h > w ? (w/h) : 1 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var img = new Image, | |
canvas = document.createElement("canvas"), | |
ctx = canvas.getContext("2d"), | |
src = "http://example.com/image"; // 外部域中的图片url | |
img.crossOrigin = "Anonymous"; | |
img.onload = function() { | |
canvas.width = img.width; | |
canvas.height = img.height; | |
ctx.drawImage( img, 0, 0 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//用window.open的方式打开一个中转页面,再在里面执行代码打开(新窗口打开) | |
function open_new_window(full_link){ | |
window.open('javascript:window.name;', '<script>location.replace("'+full_link+'")<\/script>'); | |
} | |
//其中location.replace刷新页面的方式也可以替换成html自刷新的方式 | |
var html = '<html><head><meta http-equiv='Refresh' content='0; URL=" 路径 + "' /></head><body></body></html>' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<p><canvas id="canvas" style="border:2px solid black;" width="200" height="200"></canvas> | |
<script> | |
var canvas = document.getElementById("canvas"); | |
var ctx = canvas.getContext("2d"); | |
var data = "<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'>" + | |
"<foreignObject width='100%' height='100%'>" + | |
"<div xmlns='http://www.w3.org/1999/xhtml' style='font-size:40px'>" + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseURL(url) { | |
var a = document.createElement('a'); | |
a.href = url; | |
return { | |
source: url, | |
protocol: a.protocol.replace(':',''), | |
host: a.hostname, | |
port: a.port, | |
query: a.search, | |
params: (function(){ |
OlderNewer