How do I modify a script via HTML in a Content Editor Web Part in SharePoint Designer?
-
06-10-2020 - |
Question
I can add a script or CSS in a webpart via the broswer CEWP > HTML
But how do I do the same , what more modify a CEWP with script in it when I am in SPD 2010? I can't seem to figure it out nor can see the script in the CEWP because there id not HTML ribbon button.
Solution
The way, you are trying it does not sound good. You can try it in the following way.
- Add your css in separate file like
myStyle.css
- Add your script in separate file like
myScript.js
- Now create a text file like
myCEWP.txt
Upload all the files in a assets library like Site Assets
Now open the text file and add css, js reference and also add other html.
<link href="/Site Assets/myStyle.css" rel="stylesheet" type="text/css">
<script src="/SiteAssets/myScript.js" type="text/javascript"></script>
<div >
<!-- Write other html code here -->
</div>
Now link this myCEWP.txt
file with your CEWP from browser.
Update: If you need this myCEWP.txt
file under SharePoint Source Control, see the first comment by DannyEngelman. I found a problem in Standard version 6 months back. May be it is not there now.