Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome mobile, Navigation is blocked when redirecting to SMS

I'm trying to open the SMS outbox when the user lands on a page. It does work on the Android stock browser and Firefox, but not on Chrome (it only works if they click on a link).

I'm getting the "Navigation is blocked" error, without any further explanation:

Navigation is blocked

I've tried with window.location.href, location.href, window.location, with setTimeout... but nothing.

Do you know any way to achieve this?

like image 779
the_nuts Avatar asked Jan 21 '26 21:01

the_nuts


1 Answers

I have the same problem, it seems that Chrome is blocking some request that are called using "window.location" when these calls have variables.

As a workaround, try creating an anchor, set the href attribute and click it (programatically).

var a = document.createElement('a');
a.setAttribute('href',desiredLink); //<-- this is the URL
document.body.appendChild(a);
a.click();
like image 128
ojovirtual Avatar answered Jan 23 '26 10:01

ojovirtual



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!