Posts: 256
Location: Auckland, New Zealand
|
Well since you're new to the language, what programming knowledge/experience do you have?
InnerHTML is a Microsoft proprietary extension, however, benchmarking showed it was fast for browsers that did support this, so I used this method, for the other browsers, I created patterns to extract the HTML content and had to create the elements using the DOM API. This was working on AJAX applications, which the content grabbed from the server was HTML formatted.
What you'll need to learn is how to do innerHTML using DOM API, how to strip the content using pattern matching (regular expressions).
http://mastercomputers.uni.cc/ObJAX/objax_example.js
The getMessages() function is the area that goes through DOM creation. Unfortunately I can't show you yet how to do it with your above source, so hopefully you can read through this script and understand that function (been invited out with a few friends, so just trying to be quick in answering). Basically the splits are where I wanted to seperate the text from the tags, so I could redo them. User grabs the username out of the string I'll show below, Time grabs the GMT formatted time below and Message grab what the user entered.
The content I'm working with it is:
HTML Code:
<p class="OJ_Output"><span class="OJ_UserName">Username</span>: (<span class="OJ_TimeStamp">Wed, 03 Jan 2007 20:15:55 GMT</span>) - <span class="OJ_Message">Here's the message.</span></p>
That will be inserted, either by innerHTML or appendChild(fragment), where fragment is the part of the document I had to recreate using DOM, innerHTML being easier to use. You just probably want to learn how the stripping happens and understand my patterns to understand what you need to do. If you have all the information in a string, then understanding the string and what you need to grab out of it would help, if the information varies a lot, then you may need multiple patterns to match it.
Cheers,
MC
And I apologise for leaving without answering.
__________________
#------------------------------ signature---------------------------------------------------------------------------------#
Quote:
|
I am well recognised for what I don't do than what I do. Chores are just one of those things.
|
|