content

Problem: 'file.html' is a normal html file with external 'file.js' and 'file.css' files in the head section (the normal situation). If we try to load this file via XMLHttpRequest into some div, we obtain the behavior:
Internet Explorer and Opera: Ok for 'file.html', but 'file.js' and 'file.css' are not loaded.
Firefox: Ok for 'file.html' and 'file.css', but 'file.js' is not loaded.

Testing: Click below and a button apear in the div content, but clicking it reports a error
  • loadajax('file.html')

Solution: Load 'file.html' via AJAX and 'file.js' / 'file.css' files with include_once(...)

Testing: Click below and a '100% width green button' apear in the div content ('file.css' loaded), and clicking it alerts 'Hello world' ('file.js' loaded). Refresh the page to test again.
  • include_once('file.css');
    include_once('file.js');
    loadajax('file.html');

Changing css without reload the page: (Stoyan's idea) Load css files with include_dom(...)

  • Click for 1.css using include_dom('1.css') DOM
  • Click for 2.css using include_dom('2.css') DOM