add java script to header

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Dear NopCommerce User

i was use live chat plugin support with 3.9 and it's not support for 4.1. can i run the plugin with out installing plugins file and i just link the java script in <head></head> tag as simple HTMl way.

thanks
5 years ago
Hello,

You can add javascript to your store's head tag. You will need to edit the ~/Views/Shared/_Root.Head.cshtml file. You can either link the script directly in the head tag of the page or use the Html.AppendScriptParts() to link your script.
The Html.AppnedScriptParts() is used like this:

 Html.AppendScriptParts(ResourceLocation.Footer, "~/js/public.common.js");

You can use either ResourceLocation.Footer or ResourceLocation.Head depending on where you want your script to be included.

I would just like to stress on the fact that including your plugin javascript on your store won't necessarily have the same effect as installing the 4.1 version of the plugin. I am not sure which plugin are you talking about but it might contain and need more code than just the javascript it includes to work.

Hope that helps!

Regards,
Anton
3 years ago
I don't like to change the source code ... so i tried as shown and it works !!!
I realized a workaround using Google Analytics plugin ... i need to add a scritp code to the head html.

I insered it in the same text box ad shown below ...

<!-- Google code for Analytics tracking -->
<script type="text/javascript">
...
.....
</script>

<!-- XXXX code for tracking -->
<script defer async>
</script>
<!-- XXXXX code for tracking -->
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.