commit 0b004b3d6d9f1f95072e1e4f02e6bec99efb1d6a
Author: Dmitrij D. Czarkoff <[email protected]>
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
@@ -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 <[email protected]>
+
+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;


Reply via email to