简体   繁体   中英

Sharepoint 365 doesn't render the JavaScript Code inside the Script Editor

I have having issue with SharePoint 365 where the.aspx file doesn't render the JavaScript code in the script editor. Here is my scenario:

  • I have a JavaScript script file named helloworldtest.js in my SiteAssets Folder
  • I have HelloWorld.aspx file in my SitePages Folder

JavaScript file (helloworldtest.js) has following code:

alert("Hello World! This is Test Ran by Bee");

I have added the JavaScript code in the Script Editor section on HelloWorld.aspx page. Below is the code I added in the script editor section:

<script type="text/javascript" src="../SiteAssets/helloworldtest.js"></script>

Problem: I think my java script file and script correct on the script editor in.aspx file but SharePoint 365 is not rendering the alert.

I am new to SharePoint 365 so if anyone has any experience working with SharePoint 365 script editor and have gone through this problem before, please help me out here and be kind enough to tell me your experience and solution that you adopted. Thank You!

I just tried this on my SharePoint site and it is working fie for me.

If you are adding script editor on home page of site, try using this reference to JavaScipt file in this format:

<script type="text/javascript" src="/sites/siteName/SiteAssets/helloworldtest.js"></script>

If you are adding script editor on any other page of site, below should work for you:

<script type="text/javascript" src="../SiteAssets/helloworldtest.js"></script>

Output :

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM