Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Trying to add custom data via javascript to the head tag


EFAFAdmin

Question

Site URL: https://evergreenfineartsfestival.com

Hi my site has many pages that include the current year and some other data.  I'm trying to inject that data via the head tag by clicking into Settings->Advanced->Code Injection, then on the pages using a code block to access the data.

The code injection is:

<script type="text/javascript">
  var year = "2021";
  var lastYear = "2020";
  var nextYear = "2022";
  var event = "55th";
  var friday = "27";
  var saturday = "28";
  var sunday = "29";

function docWrite(variable) {
    document.write(variable);
}
</script>

And the content looks like this in a code block:

<h2 style="text-align:center;white-space:pre-wrap;"><strong><script>docWrite(year)</script> Juror</strong></h2>

This is working fine on the home page, but on all other pages the variables aren't populated when I load the page.  I have to click on refresh to make them appear.  When I look at the page source everything appears to be where it should be.

Any ideas or help would really be appreciated!

Link to post
  • Answers 3
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

Disable ajax

3 answers to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...