How to disable the 'Open Link in New Tab' in the browser?
Have solved the main issue now, quite easily as it turned out just by passing the query string of the href to an ajax function.
I probably should have explained in my question that what I wanted was intended only as a temporary measure. Anyway thanks for all the comments.
Preventing pages being open in a new tab/window
Instead of
<a href="http://stackoverflow.com">link</a>
use
<a href="javascript:void(0);" onclick="javascript:window.location.href='http://stackoverflow.com';">link</a>
Middle mouse click opens this location in the same tab, right click -> open in new tab
opens about:blank
page.
When you can't edit every link manually you can use this script:
for(var els = document.getElementsByTagName('a'), i = els.length; i--;){
els[i].href = 'javascript:void(0);';
els[i].onclick = (function(el){
return function(){
window.location.href = el.getAttribute('data-href');
};
})(els[i]);
}
and instead of <a href="...">
use <a data-href="...">
.
Going further, you may change script above to following:
for(var els = document.getElementsByTagName('a'), i = els.length; i--;){
var href = els[i].href;
els[i].href = 'javascript:void(0);';
els[i].onclick = (function(el, href){
return function(){
window.location.href = href;
};
})(els[i], href);
}
this way links stay the same <a href="...">
, but if user has disabled JavaScript, links may be opened in another tab/window.
How to prevent to open new tab when I drag and drop image on the Chrome browser in JavaScript?
You should add preventDefault()
on all dragover
and drop
events handlers.
Example:
window.addEventListener("dragover",function(e){
e = e || event;
e.preventDefault(); <=================
},false);
window.addEventListener("drop",function(e){
e = e || event;
e.preventDefault(); <=================
},false);
More Useful link here for React
Here is the same question for drag and drop
How to stop Microsoft Edge opening Bing links in a new tab
Open https://www.bing.com/account/general#settings_results in Microsoft Edge, and you will have to disable the "Open links from search results in a new tab or window" from the 'Results' section. And click 'Save'.
Related Topics
Multiply and Sum Input Values Created Dynamically in Jquery
How to Load a Font File in Vuejs and Webpack
Datatables/Tabletools: Format Data as Text When Exporting to Excel
How to Customize Header Cell in Pdf Using Jspdf-Autotable Plugin
Javascript Check If Character Is a Vowel
How to Get Multiple Comma Separated Values from Url
How to Detect Chinese Character With Punctuation in Regex
Res.Sendfile in Node Express With Passing Data Along
How to Insert Space Every 4 Characters for Iban Registering
How to Avoid Scientific Notation for Large Numbers in JavaScript
Javascript Function (Input Date Bigger Than Today Date)
Check If a Key Exists Inside a Json Object
How to Do Validation for 10 Digit Mobile Number Using Jquery
How to Refresh an Angular Component
Modify Classname When Element Is Clicked in React