2

I am trying to replace window.open(file_path), which doesn't work satisfactorily in browser windows without toolbars (edge, chrome). With code using script clicking on anchor (simplified form SO:easiest way to open a download window without navigating away from the page)

var a = document.createElement('A');
a.href = file_path;
a.click();

The problem is that the original code has ability to detect that the window opening was blocked (popup blocker)

var wnd = window.open(docurl)
if (wnd != null) {/*...*/}

Is there a possibility detecting that the download was blocked for clicking on an anchor?

IvanH
  • 5,039
  • 14
  • 60
  • 81
  • 3
    My opinion: Stop worrying about whether people are blocking or otherwise interfering with your website. If they don't get what they want, they'll know soon enough. Just put some kind of warning on your page that downloads may be blocked and how to stop their browser from blocking them. – Heretic Monkey Dec 18 '18 at 14:38
  • 1
    Good question but I agree with @HereticMonkey ... You can add a popup if you detect an adblocker or something telling them some links might not work and ask them to whitelist your website. – Alexandre Elshobokshy Dec 18 '18 at 14:39
  • 1
    @HereticMonkey You are right I can live without but it is nice to have. – IvanH Dec 18 '18 at 14:44

0 Answers0