Forum Moderators: open

Message Too Old, No Replies

Using JavaScript to include a SSI

         

gms3651

3:59 pm on Aug 27, 2007 (gmt 0)

10+ Year Member



Hello,
I call my script.js file from the <head> on my .htm document. Below is the code that is in my .js file:

window.onload = test

function test() {
document.getElementById('video').innerHTML = "<!--#include virtual=\"includes/video.htm\" -->";
}

However, when I view the contents of my 'video' div nothing appears. When I delete the '<!--' I can see the contents in the div. However, I don't want to do this becasue then my include will not appear.

Does anybody know how to do this?

Thanks

rocknbil

9:15 am on Aug 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Honestly I've never tried this - but it seems logical that it wouldn't work, and here is why.

When you use an SSI you are asking the server to parse the file for SSI directives that can include static files, script output, or execue basic system commands prior to delivering the document to the client. When you do it with Javascript, the document has already been delivered, it doesn't re-query the server again.

If the include needs to be activated by user interaction with the page, you may consider Ajax or sending a request back to the server in some other way to refresh the page.