Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Script within script
Message
From
14/05/2018 11:12:07
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01659975
Message ID:
01659976
Views:
66
This message has been marked as the solution to the initial question of the thread.
Hi Dmitry,

1- I'd rather load this HTML fragment on server side
2- If you want to keep your AJAX request you can have this:

footer.html
<p>© my Company <span id="copyYear"></span></p>
<head>
…
<script>
  $(function () {
    $("#footer").load("footer.html", function(){$("#copyYear").html(new Date().getFullYear())}); //http://api.jquery.com/load/
  });
</script>
…
</head>
>Hi,
>
>I created a footer.html that is supposed to be shown on all pages of the site. The pages are all static, html.
>The footer.html is pretty simple. It has a P element with Copywrite and the year. But I want the year to be scripted, so that I don't have to change it every year. So the line in the footer.html that has the year is as follows:
>
><script>document.write(new Date().getFullYear());</script>
>
>
>And the way I show the Footer in the page is as follows:
>
>in the Head section:
>
> <script>
>        $(function () {
>            $("#footer").load("footer.html");
>        });
>    </script>
>
>
>And in the Page.html:
>
><div id="footer"></div>
>
>
>Everything works if I don't have the Script element in the Footer.html.
>
>How could I show the current year in the Footer.html without the script? or how do I use Script within the footer?
>
>TIA
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform