Open link in new tab or window [duplicate]

You should add the target=”_blank” and rel=”noopener noreferrer” in the anchor tag. For example: <a target=”_blank” rel=”noopener noreferrer” href=”http://your_url_here.html”>Link</a> Adding rel=”noopener noreferrer” is not mandatory, but it’s a recommended security measure. More information can be found in the links below. Source: MDN | HTML element <a> | attribute target About rel=noopener Opens External Anchors Using … Read more

How to change href of tag on button click through javascript

Without having a href, the click will reload the current page, so you need something like this: <a href=”#” onclick=”f1()”>jhhghj</a> Or prevent the scroll like this: <a href=”#” onclick=”f1(); return false;”>jhhghj</a> Or return false in your f1 function and: <a href=”#” onclick=”return f1();”>jhhghj</a> ….or, the unobtrusive way: <a href=”#” id=”abc”>jhg</a> <a href=”#” id=”myLink”>jhhghj</a> <script type=”text/javascript”> … Read more

Angular 2 router no base href set

https://angular.io/docs/ts/latest/guide/router.html Add the base element just after the <head> tag. If the app folder is the application root, as it is for our application, set the href value exactly as shown here. The <base href=”https://stackoverflow.com/”> tells the Angular router what is the static part of the URL. The router then only modifies the remaining part … Read more

window.location.href and window.open () methods in JavaScript

window.location.href is not a method, it’s a property that will tell you the current URL location of the browser. Changing the value of the property will redirect the page. window.open() is a method that you can pass a URL to that you want to open in a new window. For example: window.location.href example: window.location.href=”http://www.google.com”; //Will … Read more

href image link download on click

<a download=”custom-filename.jpg” href=”/path/to/image” title=”ImageName”> <img alt=”ImageName” src=”/path/to/image”> </a> It’s not yet fully supported caniuse, but you can use with modernizr (under Non-core detects) to check the support of the browser.