1

I'm pretty new to HTML and Javascript, so please forgive me if I misuse terminology. I am attempting to add the SermonAudio daily devotion on our home page for our employee intranet which is created in SharePoint Online.

Here is the HTML code:

<!--Begin SermonAudio Link Button-->
  <SCRIPT LANGUAGE="JavaScript" type="text/javascript" src="http://www.sermonaudio.com/code_spurgeon.asp?titlecolor=123154"></SCRIPT>
<!--End SermonAudio Link Button-->

When I attempt to put that into an "Embed Code" it doesn't display anything. What might I be missing? I've enabled custom scripts in the SharePoint admin center.

2 Answers 2

0

There are a lot of ways to require/append/include External scripts. Too many for one reply and you will learn them on your JavaScript travels.

  • declared in the MasterPage
  • appendChild
  • require
  • SOD (SharePoint Script On Demand)
  • User Custom Action - ScriptLink
  • JSLink
  • more...

Since you are on SharePoint Online the easy way is probably to set the JSLink property on (any) webpart in the page.

Notes:

  • you have a Security issues here.. SharePoint is HTTPS and your script is coming from HTTP, so use an HTTPS server or (manually) disable your browsers security settings (totally not recommended)

  • Never tried it, but I think SharePoint can NOT serve ASP files, if it does you could move your generator into a Document Library

  • since these scripts are loaded before your DOM content is created you can not use document.write

So you have to rewrite you (generated) script to store the information on the window Object.

window.myData='YOUR dynamic HTML';

then later display it with JavaScript in the DOM

document.write( window.myData );
1
  • Thanks! It turns out that all I had to do was add the S to HTTP in order to get it to work! I'll take note of your list of suggestions for the future. I need to spend some time studying javascript as soon as I can.
    – Ben Grady
    Commented Nov 14, 2016 at 16:06
0

I think you need to add the full code at script editor at your page as the following

  • Navigate to your link http://www.sermonaudio.com/code_spurgeon.asp?titlecolor=123154
  • Copy the code that will be shown .

  • Surround it with <script> tag

The final code should look like

<script>

document.write('<div style=margin-bottom:2px><font style=color:#123154; size=+1><B>"Horror hath taken hold upon me because of the wicked that forsake Thy law."</font></b></div><font color=#996600 style=font-size:12px>Psalm 119:53&nbsp;&nbsp;|&nbsp;&nbsp;Wednesday, November 02, 2016&nbsp;Evening</font><div style=padding-top:14px></div> My soul, feelest thou this holy shuddering at the sins of others? for otherwise thou lackest inward holiness. David\'s cheeks were wet with rivers of waters because of prevailing unholiness; Jeremiah desired eyes like fountains that he might lament the iniquities of Israel, and Lot was vexed with the conversation of the men of Sodom. Those upon whom the mark was set in Ezekiel\'s vision, were those who sighed and cried for the abominations of Jerusalem. It cannot but grieve gracious souls to see what pains men take to go to hell. They know the evil of sin experimentally, and they are alarmed to see others flying like moths into its blaze. Sin makes the righteous shudder, because it violates a holy law, which it is to every man\'s highest interest to keep; it pulls down the pillars of the commonwealth. Sin in others horrifies a believer, because it puts him in mind of the baseness of his own heart: when he sees a transgressor he cries with the saint mentioned by Bernard, "He fell to-day, and I may fall to-morrow." Sin to a believer is horrible, because it crucified the Saviour; he sees in every iniquity the nails and spear. How can a saved soul behold that cursed kill-Christ sin without abhorrence? Say, my heart, dost thou sensibly join in all this? It is an awful thing to insult God to His face. The good God deserves better treatment, the great God claims it, the just God will have it, or repay His adversary to his face. An awakened heart trembles at the audacity of sin, and stands alarmed at the contemplation of its punishment. How monstrous a thing is rebellion! How direful a doom is prepared for the ungodly! My soul, never laugh at sin\'s fooleries, lest thou come to smile at sin itself. It is thine enemy, and thy Lord\'s enemy--view it with detestation, for so only canst thou evidence the possession of holiness, without which no man can see the Lord.<div style=padding-top:14px></div><a style=color:#123154; target=_new href="http://www.sermonaudio.com/daily.asp"><font style=font-size:9px;font-weight:bold;font-family:verdana;text-decoration:none;>MORE</font></a><font style=color:#123154;font-size:6.5pt>&nbsp;&nbsp;|&nbsp;&nbsp;</font><a style=color:#123154; target=_new href="http://www.sermonaudio.com/rss_special.rss?type=daily"><font style=font-size:9px;font-weight:bold;font-family:verdana;text-decoration:none;>RSS</font></a><font style=color:#123154;font-size:6.5pt>&nbsp;&nbsp;|&nbsp;&nbsp;</font><a style=color:#123154; target=_new href=http://www.sermonaudio.com><font style=font-size:9px;font-weight:bold;font-family:verdana;text-decoration:none;>Powered By SERMONAUDIO.com</font></a>');
</script>
  • Edit your page > add script editor.

enter image description here

  • Click on Edit Snippet > paste the final code .

[OutPut]

enter image description here

1
  • Thank you for the quick reply! Unfortunately this solution would require me to update the script each day in order to get a daily devotion, at least from what it looks like. I'm trying to get the web part to automatically show the updated daily devotion as the authors update it. Thank you for your help!
    – Ben Grady
    Commented Nov 14, 2016 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.