Using HTML anchor link fragment in Angular 6

Angular 6.1 comes with an option called anchorScrolling that lives in router module’s ExtraOptions. As the anchorScrolling definition says: Configures if the router should scroll to the element when the url has a fragment. ‘disabled’ — does nothing (default). ‘enabled’ — scrolls to the element. This option will be the default in the future. Anchor … Read more

HTML Anchor tag redirect link after ajax request

Use event.preventDefault, then on success, use location.href = self.href $(“.selectAnchor, .menuAnchor”).click(function(event){ event.preventDefault(); console.log(event.target.nodeName); var self = this; $.ajax({ type: ‘POST’, url: ‘http://localsite/menuRedirect.php’, data: {id:0, module:’Module’,source:’Source’}, complete: function(data){ console.log(“DONE”); location.href = self.href; } }); }); Or make use of the context property to remove var self = this $(“.selectAnchor, .menuAnchor”).click(function(event){ event.preventDefault(); console.log(event.target.nodeName); $.ajax({ type: ‘POST’, context: … Read more

Auto-Scroll to next anchor at Mouse-wheel

This works in Chrome, IE, Firefox, Opera, and Safari: (function() { var delay = false; $(document).on(‘mousewheel DOMMouseScroll’, function(event) { event.preventDefault(); if(delay) return; delay = true; setTimeout(function(){delay = false},200) var wd = event.originalEvent.wheelDelta || -event.originalEvent.detail; var a= document.getElementsByTagName(‘a’); if(wd < 0) { for(var i = 0 ; i < a.length ; i++) { var t = … Read more

Is it safe to use anchor to submit form?

To use an anchor to submit a form would require the use of JavaScript to hook up the events. It’s not safe in that if a user has JavaScript disabled, you won’t be able to submit the form. For example: <form id=”form1″ action=”” method=”post”> <a href=”#” onclick=”document.getElementById(‘form1′).submit();”>Submit!</a> </form> If you’d like you can use a … Read more

How to prevent jump on an anchor click?

$(document).ready(function() { var hash = window.location.hash; var link = $(‘a’); $(‘a’).click(function(e) { e.preventDefault(); hash = link.attr(“href”); window.location = hash; }); }); You also have to specify event argument in the function. By naming it as e or event and then you can manipulate it.

How do you make a div tag into a link

JS: <div onclick=”location.href=”https://stackoverflow.com/questions/1685078/url””>content</div> jQuery: $(“div”).click(function(){ window.location=$(this).find(“a”).attr(“href”); return false; }); Make sure to use cursor:pointer for these DIVs

CodeIgniter – Correct way to link to another page in a view

I assume you are meaning “internally” within your application. you can create your own <a> tag and insert a URL in the href like this <a href=”<?php echo site_url(‘controller/function/uri’) ?>”>Link</a> OR you can use the URL helper this way to generate an <a> tag anchor(uri segments, text, attributes) So… to use it… <?php echo anchor(‘controller/function/uri’, … Read more