[wiki] [sites] Added "untarget" JS script for surf || Dmitrij D. Czarkoff
commit 0b004b3d6d9f1f95072e1e4f02e6bec99efb1d6a
Author: Dmitrij D. Czarkoff <czarkoff_AT_gmail.com>
Date: Sat Jun 6 15:28:02 2015 +0200
Added "untarget" JS script for surf
Looks for target="_blank" attributes in <A> elements and removes them.
diff --git a/surf.suckless.org/files/untarget.md b/surf.suckless.org/files/untarget.md
new file mode 100644
index 0000000..ac67436
--- /dev/null
+++ b/surf.suckless.org/files/untarget.md
_AT_@ -0,0 +1,25 @@
+Prevent "target" attribute
+==========================
+
+Description
+-----------
+
+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.)
+
+Author
+------
+
+Dmitrij D. Czarkoff <czarkoff_AT_gmail.com>
+
+Code
+----
+
+ function untarget() {
+ var links = document.getElementsByTagName('a');
+ Array.prototype.slice.call(links).forEach(function(anchor, index, arr) {
+ if (anchor["target"] == "_blank")
+ anchor.removeAttribute("target");
+ });
+ }
+
+ window.onload = untarget;
Received on Sat Jun 06 2015 - 15:29:52 CEST
This archive was generated by hypermail 2.3.0
: Thu Jun 18 2015 - 18:41:53 CEST