Is their a way to keep all pages on the internet in a single window through Chromes browser settings? or a addon/plugin that I can do this with?
I don't want web pages to open up in new tabs and/or new windows when I click on some links.
Let me know if anyone has any suggestions!, Thanks!!
<a href="http://www.bing.com" target="_blank">Opens a New Tab!</a>
<i>Thtats not what i want..., I want this link to stay in same url bar.</i>
<p>Like this!</p>
<a class="click" href="http://www.bing.com">Click Here</a>
Despite its popularity, Google Chrome is still haunted by errors. One of them is responsible for Chrome opening new tabs. This might be a sign of malware infection, so scanning your system could help. One way to fix this issue is to reset your browser to the default, or reinstall it completely.
One approach could be building an extension that injects a content script in every page. This content script would parse the DOM and remove all and set all target
attributes off the anchor elementstarget
attributes of anchor elements to _self
.
window.open()
).You could use a MutationObserver that watches for anchor elements being inserted or having their target
attribute modified and make the appropriate adjustments.
You still need to take care of tabs opened by other means (e.g. window.open()
) if it is extremely important to you (but those cases should be very very few, so it might not be worth the trouble).
manifest.json:
{
"manifest_version": 2,
"name": "Test Extension",
"version": "0.0",
"content_scripts": [{
"matches": ["*://*/*"],
"js": ["content.js"],
"run_at": "document_start",
"all_frames": true
}]
}
content.js:
/* Define helper functions */
var processAnchor = function(a) {
//if (a.hasAttribute('target')) {
// a.removeAttribute('target');
//}
a.setAttribute('target', '_self');
};
/* Define the observer for watching over inserted elements */
var insertedObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
var inserted = [].slice.call(m.addedNodes);
while (inserted.length > 0) {
var elem = inserted.shift();
[].slice.call(elem.children || []).forEach(function(el) {
inserted.push(el);
});
if (elem.nodeName === 'A') {
processAnchor(elem);
}
}
});
});
/* Define the observer for watching over
* modified attributes of anchor elements */
var modifiedObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
if ((m.type === 'attributes') && (m.target.nodeName === 'A')) {
processAnchor(m.target);
}
});
});
/* Start observing */
insertedObserver.observe(document.documentElement, {
childList: true,
subtree: true
});
modifiedObserver.observe(document.documentElement, {
attributes: true,
substree: true
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With