r/programminghorror • u/Mc_UsernameTaken [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” • Feb 20 '26
Javascript Send help please... Emergency evacuation needed.
350
Upvotes
r/programminghorror • u/Mc_UsernameTaken [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” • Feb 20 '26
126
u/MisterEd_ak Feb 20 '26
Missing the event variable in the function call and event.preventDefault();
17
u/CantaloupeCamper Feb 20 '26
What would the point of this… be?
9
u/Wuma Feb 20 '26
My best guess is at some point they were doing something like a tracking event, but then someone asked them to remove the tracking, and they didn’t remove the redundant logic
56
u/Spidron Feb 20 '26
Is this code that is meant to "sanitize" HTML in such a way, that each link is guaranteed to lead to it's href target? Maybe in situations where the code comes from some outside source (e.g. user input being reflected) and the developer was afraid that it may contain malicious onclick-script or similar?
2
u/Character-Travel3952 Feb 20 '26
I wish i could do this kind of gymnastics physically... ill def be fitter
2
u/Saqwefj Feb 20 '26
The function will end and you are fifer to go! No worries!
1
u/SnackOverflowed Feb 21 '26
Talk about reinventing the wheel
1
u/joost00719 Feb 21 '26
I've done something like this to genericly add noopener and norefer to all the a-tags 😅
1
u/FalseWait7 Feb 21 '26
I never trust browsers either and always, always talk to their apis directly.
1
u/evbruno Feb 21 '26
The horror “$link”…
1
u/valzargaming Feb 23 '26
I've seen a similar workaround like this for safari. I'm betting that's the real reason this code looks the way it does.
1
u/TheCarter01 Feb 20 '26
Looks like Javascript + JQuery
1
u/will_r3ddit_4_food Feb 21 '26
Uhh... did you time travel to 2012?
2
u/[deleted] Feb 22 '26
[removed] — view removed comment