{"action":"opened","issue":{"url":"https://api.github.com/repos/AutumnsWind/Good-text-Share/issues/6","repository_url":"https://api.github.com/repos/AutumnsWind/Good-text-Share","labels_url":"https://api.github.com/repos/AutumnsWind/Good-text-Share/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/AutumnsWind/Good-text-Share/issues/6/comments","events_url":"https://api.github.com/repos/AutumnsWind/Good-text-Share/issues/6/events","html_url":"https://github.com/AutumnsWind/Good-text-Share/issues/6","id":145138832,"number":6,"title":"前端冷知识，妙用浏览器地址栏","user":{"login":"AutumnsWind","id":10759713,"avatar_url":"https://avatars.githubusercontent.com/u/10759713?v=3","gravatar_id":"","url":"https://api.github.com/users/AutumnsWind","html_url":"https://github.com/AutumnsWind","followers_url":"https://api.github.com/users/AutumnsWind/followers","following_url":"https://api.github.com/users/AutumnsWind/following{/other_user}","gists_url":"https://api.github.com/users/AutumnsWind/gists{/gist_id}","starred_url":"https://api.github.com/users/AutumnsWind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AutumnsWind/subscriptions","organizations_url":"https://api.github.com/users/AutumnsWind/orgs","repos_url":"https://api.github.com/users/AutumnsWind/repos","events_url":"https://api.github.com/users/AutumnsWind/events{/privacy}","received_events_url":"https://api.github.com/users/AutumnsWind/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-01T09:57:41Z","updated_at":"2016-04-01T09:57:41Z","closed_at":null,"body":"javascript：会使浏览器触发js解释器\r\n`javascript:alert('I am autumnswind :)');`\r\n将以上代码贴到浏览器地址栏回车后alert正常执行，会出现一个弹窗。\r\n注意：某些浏览器的javascript: 要自行手打到浏览器地址栏，直接复制粘贴的话IE和Chrome会自动去掉代码开头的javascript:的\r\n可以拿来四则运算balabala~\r\n`javascript:alert(3+4-6);`\r\n看看圆周率等等~\r\n`javascript:alert(355/113);void(0);`\r\n深入一点，在页面上一些点击的链接可以利用这种方法实行跳转之后运行js代码，进而进行xss或者钓鱼，这里省略~\r\n```\r\n<a href=\"javascript:alert('I am autumnswind :)');\">\r\nI am autumnswind :)\r\n</a>\r\n```\r\n当然也可以用来检测是否钓鱼网站，根据提供的URL和网页本身的URL进行对比验证\r\n`javascript:alert(\"本网址域名为:\" + location.protocol + \"//\" + location.hostname + \"/\" + \"\\n此时浏览的地址为:\" + location.href + \"\\n\" + \"\\n注意：如果域名对不上，就赶紧关掉噢\");`\r\n还有一个跟这个类似的用法就是mailto\r\n`<a href=\"mailto:name@email.com\">I am autumnswind :)</a>`\r\n链接是一种html链接，能够设置你电脑中邮件的默认发送信息。但是需要你电脑中安装默认的E-mail软件，类似Microsoft Outlook等等。\r\n`data:text/html, <textarea style=\"font-size: 1.5em; width: 100%; height: 100%;\" autofocus />`\r\n将以上代码输入到浏览器将会出现一个textarea框\r\n\r\n当然你也可以更改更复杂一点，比如下面复制粘贴这两个代码到地址栏试试\r\n```\r\ndata:text/html,<button onClick=\"SaveTextArea()\">Save</button> <script language=\"javascript\" type=\"text/javascript\"> function SaveTextArea() { window.location = \"data:application/octet-stream,\" + escape(txtBody.value); } </script> <textarea id=\"txtBody\" style=\"font-size: 1.5em; width: 100%; height: 100%; boarder: none; outline: none\" autofocus> </textarea>\r\ndata:text/html, <style type=\"text/css\">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id=\"e\"></div><script src=\"\" type=\"text/javascript\" charset=\"utf-8\"></script><script>var e=ace.edit(\"e\");e.setTheme(\"ace/theme/monokai\");e.getSession().setMode(\"ace/mode/ruby\");</script>\r\n```\r\n其他的用法如下：\r\n1. data:,<文本数据>  \r\n2. data:text/plain,<文本数据>  \r\n3. data:text/html,<HTML代码>  \r\n4. data:text/html;base64,<base64编码的HTML代码>  \r\n5. data:text/css,<CSS代码>  \r\n6. data:text/css;base64,<base64编码的CSS代码>  \r\n7. data:text/javascript,<Javascript代码>  \r\n8. data:text/javascript;base64,<base64编码的Javascript代码>  \r\n9. data:image/gif;base64,base64编码的gif图片数据  \r\n10. data:image/png;base64,base64编码的png图片数据  \r\n11. data:image/jpeg;base64,base64编码的jpeg图片数据  \r\n12. data:image/x-icon;base64,base64编码的icon图片数据  \r\n\r\n就不一一介绍了\r\n[图文就放在这里吧](http://www.talkingcoder.com/code/6268522936243585073)"}}