0

I want to execute a javascript snippet that check whatever the browser supports angular or not. In the second case the script will do a redirect towards a static html webpage.

My intent is not rely on polyfills to support outdated browsers, but give a nice UX anyway by inviting the visitor to access my website with a modern browser.

Is it possible?

Phate
  • 6,066
  • 15
  • 73
  • 138

1 Answers1

1

In your main.ts

//replace this
//    platformBrowserDynamic().bootstrapModule(AppModule)
//      .catch(err => console.error(err));

//by some like:

if (executeAjavaScriptFunction())
{
  platformBrowserDynamic().bootstrapModule(AppModule)
     .catch(error=>console.log(error))
}
else
{
  alert("improve your navigator");
}

Or you can also write in your .html some like

  <app-root>
   If you can't see the application visit www.myoldpage.com
  </app-root>
Eliseo
  • 50,109
  • 4
  • 29
  • 67
  • But...if I wrote it inside of main.ts wouldn't I be forced to compile as es5 for it to be processed in IE? Moreover, wouldn't the compiler give me error if I used something like window.agent? – Phate Aug 01 '21 at 18:04