I’m using PHP, HTML & jQuery. Lets say this is my original working “index.html”
<script type="text/javascript" src="jquery.js"></script>
<script>
var p1 = "This is part 1";
var p2 = "This is part 2";
$(document).ready(function(){
alert(p1);
$('#content').html(p2);
});
</script>
<div id="content"></div>
<div id="content2">Hello</div>
I want to break the code into “index.html” & “otherFile.notSureWhatExt” but they are working as if in the same file.
index.html:
<script type="text/javascript" src="jquery.js"></script>
<script type="notSureWhatType" src="otherFile.notSureWhatExt"></script>
<script>
var p1 = "This is part 1";
$(document).ready(function(){
alert(p1);
});
</script>
<div id="content"></div>
otherFile.notSureWhatExt:
<script>
var p2 = "This is part 2";
$(document).ready(function(){
$('#content').html(p2);
});
</script>
<div id="content2">Hello</div>
Using jsp, I can simply use <%@ include file=”otherFile.anyCustomExtAlsoWorks”%>. But here I don’t now. What I want is when calling index.html, I can see message box “This is part 1” and 2 div at the bottom which is “This is part 2” & “Hello”.
I think it can be done via “server-side includes” . any way you are using php so you can make use of php. But here the file1.php or file1.html can include in file2.php. That is a php/html file can include in a php file but not one html in another html. You can go through the following links : http://webdesign.about.com/od/ssi/a/aa052002a.htm and http://www.boutell.com/newfaq/creating/include.html and even one discussion has happened in
How to include one HTML file into another?