Skip to main content

Posts

Showing posts with the label href

Why do browsers allow onmousedown JS to change href?

I've noticed for a very long time that when you try to copy a link location or open a link on Facebook, it modifies the link and passes it through l.php . For example, I can be sent to http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.google.com%2F&h=DKVUritNDJDJLDLVbldoDLFKBLOD5dlfDJY_-d3fgDUaA9b even though my browser render the link preview as http://www.google.com/ . Today, I took a closer look using Firebug and found that Facebook puts onmousedown="UntrustedLink.bootstrap($(this)[...] in the <a> tag. The second I right clicked the link, I saw the href attribute change in Firebug. This worries me. The advice many of us have given to less tech-savvy people (check where the link is taking you before you click so that you don't become a victim of phishing) now seems to have become useless. Isn't this a security risk? Can't phishing websites misuse this? Why don't browsers prevent this behavior either by disallowing onmousedown to c

Setting the id of a link based on it"s href

$('.portfolioThumbs ul li a').mouseover( function(){ var buttLink = $(this).attr('href') var buttLinkArray = buttLink.split( '/' ); // Split the URL after each / and Create an array of each var pFN = buttLinkArray[2]; // We want the Portfolio Folder Name var url = window.location.pathname; $('.galleryNav ul li a').removeClass('hovered'); $('.galleryNav ul li a' + '#' + pFN).addClass('hovered'); window.location.pathname = url + '#' + pFN; } ); This code allows me to set an ID on each button based on its href when the user "mouseover's" it. Does anyone know how this can be done automatically when the page loads, so that each button in the list gets and ID based on it's href, without any user interaction. Thanks, Dan