473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

this did not work.

So I am trying to implement the following in DOM:
document.write(str);
I was wondering if the following would do it:

document.createT*extNode(str);

So I tryed it and it showed nothing.

I was wondering what will.

Jul 26 '05 #1
5 1452
ASM
greenflame wrote:
So I am trying to implement the following in DOM:
document.write(str);
I was wondering if the following would do it:

document.createT*extNode(str);

So I tryed it and it showed nothing.


truc = document.creaTextNode(str);

create a node of text with 'str' as text and *nammed* 'truc'
*virtualy* on document
^^^^^^^^
but ...

not placed

so it is not displayed

JS wait you tell him where 'truc' has to stand

determine a 'place' to display it :
place = document.getElementById('somewhere')

insert 'truc' by its fellow 'place'
place.appenChild(truc);
or
place.parentNode.insertBefore(truc,place)

those childs, parents, (self = child of self-parent)
inserting (first, last, before), are not too easy to appropriate

Example :
=========

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>Test</title>
</head><body>
<p id="paragraphe"></p>
<script type="text/javascript">
<!--
var horodator = document.createTextNode(document.lastModified);
var precedenttext = document.createTextNode("Last modified: ");
document.getElementById("paragraphe").appendChild( precedenttext);
document.getElementById("paragraphe").appendChild( horodator);
//-->
</script>
</body></html>

appendChild inserts 'truc' in end of container 'place'

--
Stephane Moriaux et son [moins] vieux Mac
Jul 26 '05 #2
greenflame wrote:
So I am trying to implement the following in DOM:
document.write(str);
I was wondering if the following would do it:

document.createT*extNode(str);

So I tryed it and it showed nothing.

I was wondering what will.


Having created your text node, you must add it to the document. Usually
you locate a suitable element using getElementById, or have a reference
passed to your write function from a calling function, then add your
text node to that.

So for your example:

<div id="textHolder"></div>
<input type="button" value="Add some text" onclick="
addText( 'Here is some text', 'textHolder' );
">

<script type="text/javascript">
function addText( str, elID ){
var aDiv = document.getElementById( elID );
var oTxt = document.createTextNode( str );
aDiv.appendChild( str );
}
</script>

Guessing at what you might use this for, here is a showMatrix() function
that will put a matrix (array of arrays) inside a table. You pass it a
reference to the matrix and the ID of the element to put the table
inside of (it should be a div or table cell or similar block level
element that can have an other block level element inside it).

The routine will handle a matrices with one or more rows of one or more
elements, but they must be matrices (or '2D arrays'). You can add
styles for classes 'mDiv' and 'mCell' to control the appearance of the
table.
// Show a matrix in a table
function showMatrix( X, elID ){

// Locate the element to add the matrix table to
var el = document.getElementById( elID );

// Check that X really is a matrix
if ( !X
|| 'object' != typeof X
|| Array != X.constructor ) {
var msg = 'showMatrix: didn\'t get a matrix';
el.appendChild( document.createTextNode( msg ) );
return;
}

// Setup variable
var i=0, j=X.length; // row counter
var m=0, n=X[i].length; // element counter
var cr; // current row

// Start making table & components
var oT = document.createElement('table');
var oTb = document.createElement('tbody');
var oTr, oTd;

// Create a new row
while ( i < j ) {
cr = X[i++];
oTr = document.createElement('tr');
m = 0;

// Append a cell for each element with the value inside
while ( m < n ) {
oTd = document.createElement('td');
oTd.className = 'mCell';
oTd.appendChild(document.createTextNode( cr[m++] ));
oTr.appendChild( oTd );
}

// Append the row to the table body
oTb.appendChild( oTr );
}

// Add a few niceties
oT.className = 'mTable';

// Add the body to the table and the table to the document
oT.appendChild( oTb );
el.appendChild( oT );
}


--
Rob
Jul 26 '05 #3
Oh. See you gave me a url for a site that talks about displaying math
in webpages. From that I got this javascript that converts TeX to html
(with css, etc). So I just pass it the text in TeX format inside of a
span or div (depending on if I want inline or seperated math) with the
class set to math. So that is what I am using this for.

Also thanks for the help. I did not read that I need to attach the text
node to the document anywhere oh well....

Jul 27 '05 #4
greenflame wrote:
Oh. See you gave me a url for a site that talks about displaying math
in webpages. From that I got this javascript that converts TeX to html
(with css, etc). So I just pass it the text in TeX format inside of a
span or div (depending on if I want inline or seperated math) with the
class set to math. So that is what I am using this for.


Cool. Keep an eye on MathML, maybe one day it will become sufficiently
well supported that you can use it:

<URL:http://www.w3.org/Math/>

<URL:http://www.w3.org/Math/Software/>.
It hit version 1.0 in 1999 but you'd hardly know...

Poke around the links above, you'll find MathML editors, converters
(usually TeX/LaTeX to MathML) etc. Firefox/Mozilla provide native
support for MathML 1.0, IE requires a plugin.

[...]

--
Rob
Jul 27 '05 #5
Ok... I tryed it but when I looked at the page it just showed the text
and it did not parse any of it as html. How do I get it do do this?

Aug 5 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Venkat | last post by:
Hi, My HTML page doesnot work properly in Netscape 7.1. But works fine in Opera 7 and IE 6.0. I could not figure out the problem. If any one could/suggest it would be nice.. This piece of HTML...
2
by: Andrew Mogford | last post by:
Hi, We have moved a web site from a development server running Windows 2000 and IIS 5 to a Windows 2003 server running IIS 6.0 Now the asp pages do not work correctly. For example,...
0
by: Jarod_24 | last post by:
How does tabindex work in ASP .net pages I dosen't seem to work quite like in regular forms. and there isn't any TabStop property either. 1 .How do you prevent a control form beign "tabbed"....
30
by: bblais | last post by:
Hello, Let me start by saying that I am coming from a background using Matlab (or Octave), and C++. I am going to outline the basic nuts-and-bolts of how I work in these languages, and ask for...
4
by: rodchar | last post by:
hey all, i working with the Publisher object model in an ASP.NET page. When I'm working with my project locally everything works fine. However, when I deploy the application to my app server, it...
9
by: Cliff | last post by:
I've got a number of SNMP devices scattered around the globe that I want to get some information off.. I've got a couple of classes whcih get a quite complex table together from SQL and SNMP...
3
by: hscott93 | last post by:
Hello. I have a new Vista based laptop at work that connects to a Windows 2003 Small Business Server at work via an assigned, static IP address. When I take the laptop home, I have router that...
2
by: gsherp | last post by:
I can get the Onclick event handler to work when I added a new row using insertRow. It doesn't work in IE or in FF var cellarea = row.insertCell(2); cellarea.style.backgroundColor =...
0
by: wimdows | last post by:
Hi, I've successfully added custom fields to the Task Work Item template, using the Process Editor (and opening from server). However, I would like to also see these items in the field list...
1
by: FlashT | last post by:
Hello, I got a script: http://www.mattkruse.com/javascript/autocomplete/index.html It works fine on IE and Opera, but does not on FF. It does something on FF, but not what it should do (check...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.