Adding Universal Scripts to Websites

Overview

 

Sometimes, you may want to add universal codes or scripts to your websites. To do so, you must modify the skin of your website.

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 or Admin Access

 


Process

 

  1. Open the Windows File Explorer.

  2. Navigate to the folder where your DNN site is installed, and open your skin folder at /Portals/_default/skins.

  3. Open one of the folders for a specific skin. This will depend on which skins you have installed for your site.

  4. 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 /Portals/_default/Skins/Cavalier/. For portals using the Cavalier skin, the main.ascx file is commonly loaded on the many pages.

    Screen_Shot_2019-07-05_at_4.26.31_AM.png

  5. Using a text editor, edit the .ascx file and append your code to the bottom of the page.

    2_Append_Code_to_Skin.png

    <script type="text/javascript">
    console.log("my personal code");
    </script>
    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.
  6. Save the file.
  7. Restart the application. For example: Navigate to Persona Bar > Servers and click Restart Application.

  8. Browse to the site and hit on Ctrl + F5. (This clears the cache of the previous version of your page.)

 

Back to Top


Confirmation

 

  1. Right-click on the page and select View Page Source.

  2. The added code is present when viewed in View Page Source.

  3. The script executes as intended. (This requires that your included script is functional.)

 

Back to Top

Comments

0 comments

Article is closed for comments.