Overview
If you want to add universal codes or scripts to your websites across all pages, you must modify the skin of your website or add the script to the page header. This article describes the process of adding a universal code on your website.
Prerequisites
- Access to the DNN server and Read and Write permissions to the file system
- Administrator or SuperUser account.
Solution
Solution #1
-
Open the Windows File Explorer.
-
Navigate to the folder where your DNN site is installed, and open your skin folder at
SiteRoot/Portals/_default/skins
. -
Open one of the folders for a specific skin. This will depend on which skins you have installed for your site.
-
Within the skin folder, open one of the .ascx files for your skin. The file you choose will depend on which pages you want to display the script on. For example, in the image below, the default skin, main.ascx, is located at
SiteRoot/Portals/_default/Skins/Cavalier/
. For portals using the Cavalier skin, the main.ascx file is commonly loaded on the many pages. -
Using a text editor, edit the .ascx file and append your code to the bottom of the page.
<script type="text/javascript">
Notes: The source code of the .ascx file will be different if you are modifying a file that is not main.ascx from the Cavalier skin. Also, the javascript snippet is just an example, you should replace it with the real script that you wish to load on your pages.
console.log("my personal code");
</script> - Save the file.
-
Restart the application. For example: Navigate to Persona Bar > Servers and click Restart Application.
-
Browse to the site and hit on Ctrl + F5. (This clears the cache of the previous version of your page.)
Solution #2
You can add the script to the Page header for all the pages.
- Log in as an Administrator or SuperUser
- Go to Settings > Site Settings > Site Behavior
- Append the script in the HTML Page Header Tags section
- Click Save
Testing
-
Right-click on any page and select View Page Source.
-
The added code is present when viewed in View Page Source.
- The script executes as intended. (This requires that your included script is functional.)
Comments
0 comments
Article is closed for comments.