How to force fully download txt file on link?

Download file when clicking on the link (instead of navigating to the file): <a href=”https://stackoverflow.com/questions/21088376/test.txt” download>Click here</a> Download file and rename it to mytextdocument.txt: <a href=”https://stackoverflow.com/questions/21088376/test.txt” download=”mytextdocument”>Click here</a> The download attribute specifies that the target will be downloaded when a user clicks on the hyperlink. This attribute is only used if the href attribute is … Read more

HTML anchor tag with Javascript onclick event

If your onclick function returns false the default browser behaviour is cancelled. As such: <a href=”http://www.google.com” onclick=’return check()’>check</a> <script type=”text/javascript”> function check() { return false; } </script> Either way, whether google does it or not isn’t of much importance. It’s cleaner to bind your onclick functions within javascript – this way you separate your HTML … Read more

Smooth scroll anchor links WITHOUT jQuery

Extending this answer: https://stackoverflow.com/a/8918062/3851798 After defining your function of scrollTo, you can pass the element you want to scrollTo in the function. function scrollTo(element, to, duration) { if (duration <= 0) return; var difference = to – element.scrollTop; var perTick = difference / duration * 10; setTimeout(function() { element.scrollTop = element.scrollTop + perTick; if (element.scrollTop … Read more

ScrollTo function in AngularJS

Here is a simple directive that will scroll to an element on click: myApp.directive(‘scrollOnClick’, function() { return { restrict: ‘A’, link: function(scope, $elm) { $elm.on(‘click’, function() { $(“body”).animate({scrollTop: $elm.offset().top}, “slow”); }); } } }); Demo: http://plnkr.co/edit/yz1EHB8ad3C59N6PzdCD?p=preview For help creating directives, check out the videos at http://egghead.io, starting at #10 “first directive”. edit: To make it … Read more

Valid to use (anchor tag) without href attribute? [duplicate]

The <a>nchor element is simply an anchor to or from some content. Originally the HTML specification allowed for named anchors (<a name=”foo”>) and linked anchors (<a href=”#foo”>). The named anchor format is less commonly used, as the fragment identifier is now used to specify an [id] attribute (although for backwards compatibility you can still specify … Read more

Get anchor from URI

This isn’t possible as clients don’t send the “anchor part” to the server As an example, here’s the exact request that Chrome generated after submitting http://example.com/#foobar (recorded using Wireshark): GET / HTTP/1.1 Host: example.com Connection: keep-alive User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/532.3 (KHTML, like Gecko) Chrome/4.0.223.11 Safari/532.3 Cache-Control: max-age=0 Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Encoding: gzip,deflate … Read more