GithubHelp home page GithubHelp logo

Comments (9)

reed avatar reed commented on August 17, 2024 1

Try using the first method, but add these lines to the beginning of the script:

delete(window.LC_API);
delete(window.LC_Invite);
delete(window.__lc_iframe_current_skill);
delete(window.__lc_inited);
delete(window.__lc_lang);

Let me know if that works.

from turbolinks-compatibility.

maddijoyce avatar maddijoyce commented on August 17, 2024
livechat = function() {
    var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
    lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);
};

$(document).ready(livechat);
$(document).on('page:ready', livechat);

gives this error:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://secure.livechatinc.com') does not match the recipient window's origin ('http://www.mytestwebsite.test').

from turbolinks-compatibility.

maddijoyce avatar maddijoyce commented on August 17, 2024

Excellent, thanks @reed

This works:

(function() {
    delete(window.LC_API);
    delete(window.LC_Invite);
    delete(window.__lc_iframe_current_skill);
    delete(window.__lc_inited);
    delete(window.__lc_lang);
    var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
    lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);
})();

If you'd like, I can fork and add this one?

from turbolinks-compatibility.

reed avatar reed commented on August 17, 2024

That'd be great. One thing you might consider changing is in the last line, using document.body.getElementsByTagName instead of document.getElementsByTagName. That way you won't end up with duplicate script tags in the head as you navigate the site. It doesn't really make a difference, functionality-wise, so just do whichever you prefer.

from turbolinks-compatibility.

snehawatharkar avatar snehawatharkar commented on August 17, 2024

I keep getting "Script Error" on loading my site. What might be the reason and wat might fix it?

from turbolinks-compatibility.

maddijoyce avatar maddijoyce commented on August 17, 2024

Do you have a bit more info? Is "Script Error" a console error or just straight in the website? Can you include the javascript that's causing the error?

from turbolinks-compatibility.

bizappay avatar bizappay commented on August 17, 2024

I'm getting a warning message @ console saying that like attached. Hence the live chat won't appear at my website.
Screenshot-6

from turbolinks-compatibility.

faiberr avatar faiberr commented on August 17, 2024

Hi, I tried that solution and it actually works, but throw this errors on the console:
image

Any thoughts?

from turbolinks-compatibility.

faiberr avatar faiberr commented on August 17, 2024

I leave this approach here, maybe is useful to somebody else:

This code loads the script widget in all pages, but in some pages Turbolinks replaces the DOM, loosing the HTML for rendering the widget.

We use LivechatWidget.call('destroy') to kill the widget and then call the function that bring it back on those cases, that's why we use those 2 event listeners. And the property data-turbolinks-eval="false" on the script tag is important.

image

from turbolinks-compatibility.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.