简体   繁体   中英

FB link removing fbclid Ipads IOS

Having a problem my site linking directly from Facebook.

It seems to be caused from the "fbclid" get request query parameter that Facebook is adding to the link.

I have added the below JS

(function() {
var param = 'fbclid';
if (location.search.indexOf(param + '=') !== -1) {
        var replace = '';
        try {
                var url = new URL(location);
                url.searchParams.delete(param);
                replace = url.href;
        } catch (ex) {
                var regExp = new RegExp('[?&]' + param + '=.*$');
                replace = location.search.replace(regExp, '');
                replace = location.pathname + replace + location.hash;
        }
        history.replaceState(null, '', replace);
}

})();

This seems to be working for 90% of users but some IOS users are reporting issues.

Is there any reason this wouldn't work for them?

Some older versions of iOS might not have support for the History API.

It would be gross, but you could just redirect users on the client side using

window.location.replace(replace);

A better solution would be to rewrite the URL on the server side using the web server or application logic.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM