preventdefault

How to click a link that will execute but not redirect.

拟墨画扇 提交于 2021-02-10 05:50:16
问题 I have a few products in a mySQL database whose links are being retrieved in my script with $producturl. These url's actually add the product to the cart (http://www.example.com/cart/?add-to-cart=1127). I am trying to create a script that will allow the user to add products to the cart but NOT redirect them, just execute the link so the user stays on the same page. I am using preventDefault and stopPropgation but it is not working. The alert shows up but the link itself is not executing when

How to click a link that will execute but not redirect.

巧了我就是萌 提交于 2021-02-10 05:49:30
问题 I have a few products in a mySQL database whose links are being retrieved in my script with $producturl. These url's actually add the product to the cart (http://www.example.com/cart/?add-to-cart=1127). I am trying to create a script that will allow the user to add products to the cart but NOT redirect them, just execute the link so the user stays on the same page. I am using preventDefault and stopPropgation but it is not working. The alert shows up but the link itself is not executing when

Forcing CodeIgniter to send view and stop working

被刻印的时光 ゝ 提交于 2021-02-09 08:21:49
问题 Hello I'm using inherited controllers. These are my controllers: -baseAdminController: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class _BaseAdminController extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('session'); $calledFunction= $this->router->fetch_method(); if ($calledFunction!= 'loginView' && $calledFunction!= 'doLogin') { $this->checkSession(); } } public function checkSession() { if ($this->session-

Forcing CodeIgniter to send view and stop working

。_饼干妹妹 提交于 2021-02-09 08:20:28
问题 Hello I'm using inherited controllers. These are my controllers: -baseAdminController: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class _BaseAdminController extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('session'); $calledFunction= $this->router->fetch_method(); if ($calledFunction!= 'loginView' && $calledFunction!= 'doLogin') { $this->checkSession(); } } public function checkSession() { if ($this->session-

Forcing CodeIgniter to send view and stop working

房东的猫 提交于 2021-02-09 08:20:28
问题 Hello I'm using inherited controllers. These are my controllers: -baseAdminController: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class _BaseAdminController extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('session'); $calledFunction= $this->router->fetch_method(); if ($calledFunction!= 'loginView' && $calledFunction!= 'doLogin') { $this->checkSession(); } } public function checkSession() { if ($this->session-

Why do <select multiple> boxes scroll to the top with preventDefault in Chrome [duplicate]

落花浮王杯 提交于 2021-02-05 07:47:06
问题 This question already has answers here : Selecting multiple from an html select element without using ctrl key (7 answers) Closed 3 years ago . Every time I add an event listner that somehow does a preventDefault on a change to the select-box, it scrolls to the top. For a minimal example, see below: document.getElementById('foo').onmousedown = function(e) { e.target.parentElement.focus(); e.target.selected = !e.target.selected; e.preventDefault(); return false; } <select multiple size="5" id=

JavaScript - Prevent default in html5 video tag while fullscreen

≯℡__Kan透↙ 提交于 2021-01-29 18:55:07
问题 I have a video player on my website and want to change the default seek time when a user clicks left or right arrows to 10 seconds (like netflix or youtube). Using a combination of preventDefault() and stopImmediatePropagation() I've managed to achieve desired effect however when a user goes fullscreen, default events are still passed through (along with my code). document.onkeydown = function(event) { switch (event.keyCode) { case 37: event.preventDefault(); event.stopImmediatePropagation();

listen to 'CTRL+N' with javascript

旧巷老猫 提交于 2021-01-05 07:14:49
问题 I am trying to bind the 'CTRL+N' key combination, like this: var ctrlPressed = false; var nCode = 78; var ctrlCode = 224; var cmdCode = 17; document.addEventListener ("keydown", function(e){ if( e.keyCode == ctrlCode || e.keyCode == cmdCode){ ctrlPressed = true; }else{ ctrlPressed = false; } console.log(e.keyCode); }); document.addEventListener ("keyup", function(e){ if(ctrlPressed && e.keyCode == nCode){ e.preventDefault(); nou_element(parent); return; } }); Please note: jQuery isn't

Stop page refresh after form submit

做~自己de王妃 提交于 2020-12-27 06:24:46
问题 I have searched many other threads about this and I can't see what I am doing wrong, I am trying to send form values to a php file to send as an email, however the pages always refreshes. I have tried using event.preventDefault and return false both before and after my ajax call but none seem to work. What am I missing here here is my code. HTML <form method="post" name="registerForm" class="form"> <label for="fullName" class="form__fullname form__label">Full Name</label> <input type="text"

Vue.js: How to prevent browser from going to href link and instead only execute the @click method?

坚强是说给别人听的谎言 提交于 2020-12-25 06:13:42
问题 So I have a link in my application like this: <a href="/threads/my-first-thread/" @click="openThread">My first thread</a> At the moment, when I click the link, the browsers follows the href link and also executes the "openThread" method. I want to keep the link in there so that it shows the user where a click is going to bring him to, but I don't want the browser to actually follow the link (I open a lightbox instead and change the url with pushState). I want it to only execute the given