Using wixLocation for redirecting to a file

Hey,

I want a page to redirect to PDF file and show it (not download it).

Since WIX is still not supporting customize document URL on its own domain - this should be a workaround.

Using wixLocation with wix:document (internal) doesn’t seem to work as it creates a blocked pop up.

Using wixLocation with static URL from WIX (external) doesn’t work on mobile as it downloads the file instead of showing it (on desktop it works fine).

Example:

import wixLocation from 'wix-location';

$w.onReady(function () {

 wixLocation.to('wix:document://v1/ugd/myfile.pdf'); //creates blocked pop up on dektop+mobile

 wixLocation.to("https://staticaddress/myfile.pdf"); //downloads the file on mobile 

}

Any idea how to solve it?

Many thanks!

Try redirecting to the full url, not to the Wix internal src.
Something like:

wixLocation.to("https://5361b474-b6b7-4a60-afa5-eb7a001ddcee.usrfiles.com/ugd/5361b4_e15c9ece734d4ff588a337c25d90182f.pdf");

P.S I tried it on my iphone and it worked as expected (on chrome as well as on Safari).

J.D. thanks for the quick response

I have already tried: I referred to it as static URL from WIX (external), and in the code as:

wixLocation.to("https://staticaddress/myfile.pdf");

On Android it doesn’t work, so good to know on iPhone it does.

The thing is: using this full URL outside wixLocation (like through whatsapp or email) works just fine, but not within the WIX site.

@rotemabir what browser do you use?

@jonatandor35 On Desktop it works with Firefox and Chrome
On Mobile with Chrome and I can’t get it working

@rotemabir It sounds weird and I can’t explain it off the top of my head.
have you tried to see if it works fine when you use a short redirecting URL such as https://tinyurl.com ?

@jonatandor35 I did so and now even by just placing the new Tinyurl in the mobile browser it began downloading it!

So… asked another Android user to check and he has the option to open or save. Then I guess it’s just some setting on the mobile Chrome which I couldn’t find :dizzy_face:

I think you got it. Now it became an Android mystery rather than a WIX riddle.

Thank you so much for your help!!