When scraping a website containing a button that navigates to a pdf file when clicked, I would normally remove target="_blank" attribute to prevent from opening in a new tab. However, this time around, clicking the button triggers some function like this: ng-click="$ctrl.openPriceList()"
, pdf gets open in a new tab and removing target attribute on button element does nothing. How to prevent opening in a new tab in such case?
You can override window.open
:
((window, open) => {
window.open = (url) => {
open.call(window, url, '_self');
};
})(window, window.open);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.