commit 0b004b3d6d9f1f95072e1e4f02e6bec99efb1d6a parent d0e0e0ffd30e40dc67abe4b365f1143949eb8a9f Author: Dmitrij D. Czarkoff <czarkoff@gmail.com> Date: Sat, 6 Jun 2015 15:28:02 +0200 Added "untarget" JS script for surf Looks for target="_blank" attributes in <A> elements and removes them. Diffstat:
A | surf.suckless.org/files/untarget.md | | | 25 | +++++++++++++++++++++++++ |
1 file changed, 25 insertions(+), 0 deletions(-)
diff --git a/surf.suckless.org/files/untarget.md 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 <czarkoff@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;