pgscweb Posted August 25, 2017 Share Posted August 25, 2017 I use w3-include-html to bring in certain portions of a website. I noticed on our footer page that has javascript within the html snippet does not work. Is there a way to get it to work using this library? Is there a work around? Thanks in advance! Link to comment Share on other sites More sharing options...
dsonesuk Posted August 25, 2017 Share Posted August 25, 2017 The JavaScript has to be run from the page it included in, by using callback https://www.w3schools.com/w3js/w3js_include.asp For example <div w3-include-html="Footer.html"></div> <script> function dothis() { x = document.getElementById("test"); if (x) { alert(x.nodeName); } } w3IncludeHTML(dothis); </script> Footer.html <h1 id="test">Hello from footer</h1> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now