Centaurette Posted March 20, 2018 Share Posted March 20, 2018 (edited) I tried including the 'tab.html' and ‘content.html’ into my 'index.html' (using w3school code: how to include HTML, found at: https://www.w3schools.com/howto/howto_html_include.asp), but the javascript and css elements do not work. The buttons don't work as intended. Look at:https://rads-198409.appspot.com If you minimize the browser window, the tab is supposed to change to a drop-down menu, but the button does not work at all. I have checked the individual pages and they seem to work just fine, just not when they are combined. Am I doing something wrong? Could someone help? All the code I used is from w3school and I have only modified the file names (tab.html and content .html to point to the right files). Below are links to the code: Code for ‘tab.html’ - https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_topnav Code for ‘content.html’ - https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_collapsible_symbol Code for ‘index.html’ - https://www.w3schools.com/howto/tryit.asp?filename=tryhow_html_include_2 Edited March 20, 2018 by Centaurette Link to comment Share on other sites More sharing options...
dsonesuk Posted March 20, 2018 Share Posted March 20, 2018 The idea is to have one main page and include ONLY the specific relavent html code you wish to insert, no doctype, head, body, html tags, as all of these will be within the main document you are including into. Link to comment Share on other sites More sharing options...
Centaurette Posted March 20, 2018 Author Share Posted March 20, 2018 I deleted all those too when I was attempting to troubleshoot- didn’t work. The code is displayed, but doesn’t work as intended. Link to comment Share on other sites More sharing options...
dsonesuk Posted March 20, 2018 Share Posted March 20, 2018 Nevertheless the way I explained to you on how it should be done, is the correct method, just because it didn't work, doesn't mean it is wrong. When the page is fully loaded and you view the source you should see singular <!doctype html>, <html><head>...</head><body>...</body></html> tags with content, usually duplicate of these are highlighted in red meaning it is a error. There maybe a issue with including html and the applying of events, before the html actually exists, especially for collapsible JavaScript code. you could try using setTimeout() to wait a second before applying the events. Link to comment Share on other sites More sharing options...
Isaac Posted April 11, 2019 Share Posted April 11, 2019 Try checking consolelog, I checked and it turns out that the protocol being used by my computer or browser to access the HTML files is being blocked, since I had no problem with this when I pushed to GitHub, I assume it's a local problem. 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