div ID question, innerhtml

L

lhjayunaz

<div id=why>thank you</div>

<script>
var convertnow = "hello hello";
document.getElementById("why").innerHTML = convertnow
</script>


can someone please help me resolve this, i want to keep whitespace
 
T

Thomas 'PointedEars' Lahn

<div id=why>thank you</div>

<script>
var convertnow = "hello hello";
document.getElementById("why").innerHTML = convertnow
</script>

can someone please help me resolve this, i want to keep whitespace

Although the reason for that wish is beyond me: just don't use the
proprietary `innerHTML' property.

<script type="text/javascript">
var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}

var convertnow = "hello hello";
why.appendChild(why.createTextNode(convertnow));
</script>

The usual feature tests should be applied.


PointedEars
 
L

lhjayunaz

Although the reason for that wish is beyond me: just don't use the
proprietary `innerHTML' property.

<script type="text/javascript">
var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}

var convertnow = "hello hello";
why.appendChild(why.createTextNode(convertnow));
</script>

The usual feature tests should be applied.

PointedEars

Sorry, could you represent that in a executable state?
 
T

Thomas 'PointedEars' Lahn

Although the reason for that wish is beyond me: just don't use the
proprietary `innerHTML' property.

<script type="text/javascript">
var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}

var convertnow = "hello hello";
why.appendChild(why.createTextNode(convertnow));
</script>

The usual feature tests should be applied.
[...]
Sorry, could you represent that in a executable state?

Pardon?


PointedEars
 
L

lhjayunaz

(e-mail address removed) wrote:
<div id=why>thank you</div>
<script>
var convertnow = "hello hello";
document.getElementById("why").innerHTML = convertnow
</script>
can someone please help me resolve this, i want to keep whitespace
Although the reason for that wish is beyond me: just don't use the
proprietary `innerHTML' property.
<script type="text/javascript">
var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}
var convertnow = "hello hello";
why.appendChild(why.createTextNode(convertnow));
</script>
The usual feature tests should be applied.
[...]
Sorry, could you represent that in a executable state?

Pardon?

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <[email protected]>


can you please show me extra test code so I can see this in action? :)
 
G

Gregor Kofler

(e-mail address removed) meinte:
can you please show me extra test code so I can see this in action? :)

Er... replace your <script>...</script> with the offered alternative.

Gregor
 
L

lhjayunaz

(e-mail address removed) meinte:


Er... replace your <script>...</script> with the offered alternative.

Gregor

--http://www.gregorkofler.at::: Landschafts- und Reisefotografiehttp://www.licht-blick.at ::: Forum für Multivisionsvorträgehttp://www.image2d..com ::: Bildagentur für den alpinen Raum

At least with IE 6.0 Windows XP it brings back a Javascript error
"Object does not support this property or method.", with this exact
code,

<div id=why>thank you</div>

<script>
var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}

var convertnow = "hello hello";
why.appendChild(why.createTextNode(convertnow));
</script>
 
T

Thomas 'PointedEars' Lahn

[...] Thomas 'PointedEars' Lahn [...] wrote:
(e-mail address removed) wrote:
<div id=why>thank you</div>
<script>
var convertnow = "hello hello";
document.getElementById("why").innerHTML = convertnow
</script>
can someone please help me resolve this, i want to keep whitespace
Although the reason for that wish is beyond me: just don't use the
proprietary `innerHTML' property.
<script type="text/javascript">
[...] var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}
var convertnow = "hello hello";
why.appendChild(why.createTextNode(convertnow));
</script>
The usual feature tests should be applied.
[...]
Sorry, could you represent that in a executable state?
Pardon?
[...]

can you please show me extra test code so I can see this in action? :)

You can copypaste this code into your HTML document in place of your
`<script>...</script>'. It should work in all browsers capable of
scripting W3C DOM 1+ Core interfaces if the underlying markup is Valid
(http://validator.w3.org/).

Please trim your quotes:

http://www.jibbering.com/faq/faq_notes/faq_notes.html


PointedEars
 
L

lhjayunaz

You can copypaste this code into your HTML document in place of your
`<script>...</script>'. It should work in all browsers capable of
scripting W3C DOM 1+ Core interfaces if the underlying markup is Valid
(http://validator.w3.org/).

Sorry, my other post was truncated, the file you posted does not
actually work as presented. Can you run that and see?

this is the exact code I am running (IE6.0/WINXP), thank you for
checking

<div id=why>thank you</div>

<script>
var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}

var convertnow = "hello hello";
why.appendChild(why.createTextNode(convertnow));
</script>
 
G

Gregor Kofler

(e-mail address removed) meinte:
At least with IE 6.0 Windows XP it brings back a Javascript error
"Object does not support this property or method.", with this exact
code,

Any other browser, too.
<div id=why>thank you</div>

<script>
var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}

var convertnow = "hello hello";
why.appendChild(why.createTextNode(convertnow));

I suppose this should be document.createTextNode(convertnow);


Gregor
 
T

Thomas 'PointedEars' Lahn

You can copypaste this code into your HTML document in place of your
`<script>...</script>'. It should work in all browsers capable of
scripting W3C DOM 1+ Core interfaces if the underlying markup is Valid
(http://validator.w3.org/).

[...] the file you posted does not actually work as presented.
Can you run that and see?

Usually not. This newsgroup is no code factory. You should run it yourself
and see why it fails, see the FAQ Notes. I did not even post the exact code
you posted below.

However, I have just discovered a typo in this quickhack. So replace
`why.createTextNode' with `document.createTextNode' and it should work in
the mentioned environments.


PointedEars
 
L

lhjayunaz

Gregor

--http://www.gregorkofler.at::: Landschafts- und Reisefotografiehttp://www.licht-blick.at ::: Forum für Multivisionsvorträgehttp://www.image2d..com ::: Bildagentur für den alpinen Raum

No worries. The implemented changed you have, hopefully and you have
been helpful, can you see what it is going to do wrong below? :)
Your code looks very strong and I do appreciate it, in the wild
west :) Thank you.

THANK YOU.

BEST

<div id=why1>thank you</div>


<div id=why>thank you - still no cheeese :'-( </div>




<script>
var why = document.getElementById("why");
while (why.firstChild)
{
why.removeChild(why.firstChild);
}

var convertnow = "hello hello";
document.createTextNode(convertnow);
</script>
 
L

lhjayunaz

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <[email protected]>

I don't know if I got my answer, but hopefully someone has figured
this out. The code you have is way to complex to understand, and I
can't get past two errors in it, but maybe there is something I am
missing. :) Please help if you can :|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top