index.md - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
index.md (635B)
---
1 Prevent "target" attribute
2 ==========================
3
4 Description
5 -----------
6
7 This script looks for links with "target" attribute set to "_blank" and strips this attribute. This prevents surf from unexpectedy opening new windows. (Opening new windows by middle click or via context menu still works.)
8
9 Author
10 ------
11
12 Dmitrij D. Czarkoff <czarkoff@gmail.com>
13
14 Code
15 ----
16
17 function untarget() {
18 var links = document.getElementsByTagName('a');
19 Array.prototype.slice.call(links).forEach(function(anchor, index, arr) {
20 if (anchor["target"] == "_blank")
21 anchor.removeAttribute("target");
22 });
23 }
24
25 window.onload = untarget;