PDA

View Full Version : [SOLVED] Javascript File Parsing



Mr.Macdonald
May 28th, 2008, 07:10 PM
I am completeing my final project in Web page design (I don't want you to do it for me!)

I am trying to make dynamic pages and to do so i must use javascript because python php etc. would comprimise my teachers self image.

Can you, using javascript, parse a reletive html file and display its contents into a div (whatever that stands for). I know you can't read or write files but i was hoping that i could make a bunch of separate pages and display them based upon the users selection. similar to frames in html but without frames.

I need this so i don't have to write several web pages into javascript.

slavik
May 28th, 2008, 08:11 PM
what you are reffering to is called AJAX, and divs have a field called innerHTML :)

wc3schools has everything on this subject with sample code.

Mr.Macdonald
May 29th, 2008, 06:11 PM
Could i do AJAX on a computer without installing/downloading OR ANYTHING LIKE THAT. Because downloading is a violation of the class rules due to "security".

Jonne
May 29th, 2008, 06:18 PM
it's just a javascript technique. I'd recommend using a framework like jquery, which makes it all a bit easier.

But IMHO there's no point in using AJAX if the information you're going to load is static anyway.

Mr.Macdonald
May 29th, 2008, 07:30 PM
I used iframes to solve it

LaRoza
May 29th, 2008, 07:39 PM
what you are reffering to is called AJAX, and divs have a field called innerHTML :)

wc3schools has everything on this subject with sample code.

*twitch* innerHTML isn't standard and it is a "MS" thing.

Try to stick with standard interfaces like the DOM.

Jonne
May 29th, 2008, 07:56 PM
InnerHTML is supported by all browsers, and it has its uses. Using the DOM to add complex html is a pain. You have to watch out for differences between browsers sometimes, though (but then again, that's the case with pretty much everything).

Can+~
May 29th, 2008, 07:57 PM
I used iframes to solve it

Ugh.

LaRoza
May 29th, 2008, 08:10 PM
InnerHTML is supported by all browsers, and it has its uses. Using the DOM to add complex html is a pain. You have to watch out for differences between browsers sometimes, though (but then again, that's the case with pretty much everything).

"All browsers"? Will it be in the future? Using the DOM may take a little more code, but that is easy to abstract away.

slavik
May 29th, 2008, 08:37 PM
*twitch* innerHTML isn't standard and it is a "MS" thing.

Try to stick with standard interfaces like the DOM.
it works on firefox ...

LaRoza
May 29th, 2008, 08:57 PM
it works on firefox ...

Proprietary markup and API's are a poor practice. Not everyone uses firefox (I don't, although I test in it)