I can disable opening new tab or window in case of <a>
tag by removing target
attribute e.g. target='_blank'
In some cases instead of <a>
website put <button>
and add onClick()
or submit()
etc which programmatically generates a link and sets the target
attribute.
<button id="653cde4c-1620-11ec-85b5-5ae26c154b46">
<div>click here</div>
</button>
In some webpack generated javascript file there would be something like which would not be easy to find and read minified code.
var button = document.querySelctor('653cde4c-1620-11ec-85b5-5ae26c154b46')
// Add whatever you want to add to this button element, e.g. add onClick() or submit() or something else which I am not sure of
We can see image at https://i.stack.imgur.com/8oG5w.png
In such case where <button>
is providing link click functionality. I can not view and edit onClick()
or submit()
etc as its webpack generated javascript. I can only run my javascript code after loading of that webapge in devtools console
.
How can I disable opening new tab or new window of browser in such case? Or What javascript code should I run to override <button>
link behaviour?