-

2011年8月3日星期三

Help with to much content?

-hey guys ... so i have a lot of content like 10 pages :)) (i know it make no sens)



anyway ... i want to make a page but not to put all the content in the same page ....



so i have index.html and i could write like a veryyyyyyyyy huge file but i want instead to have more documents but to open them in index.html.



i have 10 lessons and i want to take lesson1.doc or html and place it in index.html when click on a link and so on ... any help??The only way I can think to do this without using iframes is to use AJAX.

The link to each html document would execute Javascript, which would load the the document behind the scenes and place the contents in a <div>.

Load another document, and it would replace the contents of the <div> with the new document.



Why do you want to open these in the index.html anyway?

____

If you use Google's jquery API, you can have code like this:



<script src="https://ajax.googleapis.com/ajax/li鈥?br>
<script type="text/javascript">

function getLesson(lesson_url) {

$.get(lesson_url, null,

function(data) {

var d = document.getElementById("lessondiv");

d.innerHTML = data;

}

);

}

</script>





and in the HTML:



<a href="getLesson('lesson1.html');">View lesson1</a>


<a href="getLesson('lesson2.html');">View lesson2</a>


...

...

<div id="lessondiv"></div>





Using this, you wouldn't have to put all 10 lessons in one page. Just 10 links in one page.If my understanding is correct...



You would have something like this:



<a href="FILEPATH_OF_LESSON_ONE">Lesson 1</a>

<a href="FILEPATH_OF_LESSON_TWO">Lesson 2</a>



etc.



example:



<a href="C:/Users/Michael/My Documents/Lesson1.doc">Lesson 1</a>



Michael is just a random name.



Or do you mean something else?

没有评论:

发表评论