0

I have a 3rd party hosted script I wish to execute, but within a conditional loading script.

Loader:

<script>

  if (typeof({{Session alive}}) == "undefined") {
 <!-- 3rd party script I wish to execute -->

 }

var d = new Date();
d.setTime(d.getTime()+1800000);
var expires = "expires="+d.toGMTString();
document.cookie = "session=1; "+expires+"; path=/";
</script>

The 3rd party script I wish to execute is:

<script type='text/javascript' src='https://www.geolify.com/georedirect.php?id=7190'></script>

is there a way to have this 3rd party script execute only within the logic of the first container, while keeping the 3rd party script hosted on the external server still.

Any help ofcourse is much appreciated, thanks very much :)

Simon Hill
  • 26
  • 2
  • Just create a script element and add it to the document; not sure what the problem is. – Ja͢ck Jun 23 '15 at 04:01
  • 1
    Maybe this [SO](http://stackoverflow.com/questions/15521343/conditionally-load-javascript-file) link will help. – Phoenix Jun 23 '15 at 04:02
  • lazy load it, lazy load – dmi3y Jun 23 '15 at 04:05
  • I should also add: the business logic of this was to load and execute an external js file, but only once per session on the original visit. – Simon Hill Jun 23 '15 at 04:07
  • @Phoenix thank yout for sharing. Using that example would this final script work you think? `` – Simon Hill Jun 23 '15 at 05:01

0 Answers0