JavaScript getElement by href?

2016 update It’s been over 4 years since this question was posted and things progressed quite a bit. You can’t use: var els = document.getElementsByTagName(“a[href=”http://domain.example”]”); but what you can use is: var els = document.querySelectorAll(“a[href=”http://domain.example”]”); (Note: see below for browser support) which would make the code from your question work exactly as you expect: for … Read more

Open Google map with specific address in a browser

You can do it like this: this is your href: http://maps.google.com/?q= everything that goes after q will be filled in the search filled and submitted, for example: 1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003 So the link looks like this: <a href=”http://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003″>…</a> If you need … Read more

Make anchor links refer to the current page when using

I found a solution on this site: using-base-href-with-anchors that doesn’t require jQuery, and here is a working snippet: <base href=”https://example.com/”> <a href=”http://stackoverflow.com/test”>/test</a> <a href=”javascript:;” onclick=”document.location.hash=”test”;”>Anchor</a> Or without inline JavaScript, something like this: document.addEventListener(‘DOMContentLoaded’, function(){ var es = document.getElementsByTagName(‘a’) for(var i=0; i<es.length; i++){ es[i].addEventListener(‘click’, function(e) { e.preventDefault() document.location.hash = e.target.getAttribute(‘href’) }) } })

Removing underline with href attribute [duplicate]

Add a style with the attribute text-decoration:none;: There are a number of different ways of doing this. Inline style: <a href=”https://stackoverflow.com/questions/12528316/xxx.html” style=”text-decoration:none;”>goto this link</a> Inline stylesheet: <html> <head> <style type=”text/css”> a { text-decoration:none; } </style> </head> <body> <a href=”https://stackoverflow.com/questions/12528316/xxx.html”>goto this link</a> </body> </html> External stylesheet: <html> <head> <link rel=”Stylesheet” href=”https://stackoverflow.com/questions/12528316/stylesheet.css” /> </head> <body> <a href=”https://stackoverflow.com/questions/12528316/xxx.html”>goto … Read more

Test if links are external with jQuery / javascript?

I know this post is old but it still shows at the top of results so I wanted to offer another approach. I see all the regex checks on an anchor element, but why not just use window.location.host and check against the element’s host property? function link_is_external(link_element) { return (link_element.host !== window.location.host); } With jQuery: … Read more

What is the difference between the different methods of putting JavaScript code in an ?

I quite enjoy Matt Kruse’s Javascript Best Practices article. In it, he states that using the href section to execute JavaScript code is a bad idea. Even though you have stated that your users must have JavaScript enabled, there’s no reason you can’t have a simple HTML page that all your JavaScript links can point … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)