Bug Tracker

Opened 6 years ago

Closed 6 years ago

#14526 closed bug (notabug)

JQuery .load() - Script Tag Error

Reported by: bryancounts@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Description

I have two pages, (1) home.html (2) includes/footer.html

I am trying to use the .load() function to load the footer file into the home page file so I do not have to replace the footer on each site page everytime I make a change to it.

I am using the current code to .load() successfully:

<div class="footer_load"> 
  <script>
  $('.footer_load').load('includes/footer.html');
  </script> 
</div>

However, when I load the footer everything comes through properly but the <script> tags that are inserted into the page. How can I re-write my code to not only import the HTML but also all other content like <script> tags that may be present.

My footer page looks like such, you can see the script tag that is used to help auto-update the copyright year. Please note the other half of the <script> defining the year attributes is located on the home.html page ... I just need the .load() function to import the half found on the footer.html page so it will all work together and render the year, while loading all the other content too.

<footer>
  <div id="copyright"><span>Copyright &copy; <script type="text/javascript"><!--- Hide from old browsers
    document.write(y0);// end hiding ---> 
    </script> Film, Stage & Showbiz Expo LLC. All Rights Reserved. All other<br>
    trademarks are the property of their respective owners and are used with their permission.
</footer>

Change History (1)

comment:1 Changed 6 years ago by dmethvin

Resolution: notabug
Status: newclosed

Please ask for help on a forum. You can't document.write() something in a template that you .load(). Scripts in a template are a bad idea in general.

Note: See TracTickets for help on using tickets.