My client wants to add the live chat script code from here website, but he wants it to put on the specific menu /contact-menu/ I'm not how I could implement it. please let me know any thoughts about this I'm not really familiar in javascript
this is the javascript for live chat:
<script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
<script type="text/javascript">window.Beacon('init', '602b66a1-948e-493f-b0dd-c2828b2eb860')</script>
Thanks
My client wants to add the live chat script code from here website, but he wants it to put on the specific menu /contact-menu/ I'm not how I could implement it. please let me know any thoughts about this I'm not really familiar in javascript
this is the javascript for live chat:
<script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
<script type="text/javascript">window.Beacon('init', '602b66a1-948e-493f-b0dd-c2828b2eb860')</script>
Thanks
Share Improve this question edited Oct 10, 2019 at 7:05 Jacob Peattie 44.2k10 gold badges50 silver badges64 bronze badges asked Oct 10, 2019 at 4:37 Jake SampanJake Sampan 11 bronze badge 2- is /contact-menu/ a page? – majick Commented Oct 10, 2019 at 4:56
- I've moved to draft the /contact-us/ page, as for now I only put custom menu which contacts us. are they any code to put the contact menu? – Jake Sampan Commented Oct 11, 2019 at 5:54
1 Answer
Reset to default 0Use add_action
to add a function to the wp_footer
hook, and then inside the function you can check if you are on a specific page before outputting the script.
eg. the Help Scout scripts on the /contact-us/
page:
add_action('wp_footer', 'maybe_add_javascript');
function maybe_add_javascript() {
if (!is_page('contact-us')) {return;}
?>
<script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
<script type="text/javascript">window.Beacon('init', '602b66a1-948e-493f-b0dd-c2828b2eb860')</script>
<?php
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745090165a4610647.html
评论列表(0条)