473,395 Members | 1,986 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,395 software developers and data experts.

Javascript Works on Most Browsers - but Not in IE6?

I have a Javascript that works in Netscape 7/Windows, Safari/Mac,
Firefox/Mac, Opera/Mac, and IE5/Mac, but not in IE6/Windows.

Here's the javascript:

<!----- JAVA ----->
<script type="text/javascript">
<!--
function ReloadTextDiv()
{
var NewText = document.getElementById("dynamictext").value;
splitText = NewText.split(/\n\n/).join("</p><p>");
splitText = splitText.split(/\n/).join("<br />");
var DivElement = document.getElementById("textdisplay");
if (splitText == '') {
DivElement.innerHTML = '<p>Start typing to preview your
comment...</p>';
} else {
DivElement.innerHTML = '<p>' + splitText + '</p>';
}
}
//-->
</script>
<!----- JAVA ----->

Here's the HTML that calls it:

<!----- HTML ----->
<p>
<textarea name="comment" id="dynamictext" name="dynamictext"
rows="12" cols="60" onkeyup="ReloadTextDiv();">{comment}</textarea>
</p>

<br/>
<br/>

<div id="comment_container">
<div id="comment_header">
<h1>Live Preview:</h1>
</div>

<div id="comment_content">
<p><span id="textdisplay">Start typing to preview your
comment...</span></p>
</div>
</div>
<!----- HTML ----->

Just in case it's relevant, here's the CSS:

<!----- CSS ----->
#comment_content
{
border: 0;}

div#comment_container{width:95%;margin: 0 auto;background:
#E7E7E7;text-align:left; font-size: 12px; min-height: 127px;}
#comment_container img {border: 0;}

div#comment_header{margin-bottom: 20px;text-align:right;}
#comment_header h1{font-size: 120%;margin:0;padding: 0
5px;background: #9DADC6;color: #FFF; font-size: 12px;}
#comment_container p{margin:0;padding-bottom:0.7em;}
<!----- CSS ----->
How can I make this Javascript work on IE6? Thanks very much in advance
to all for any info.
-Vik
Jul 23 '05 #1
5 1351
Vik Rubenfeld wrote:
I have a Javascript that works in Netscape 7/Windows, Safari/Mac,
Firefox/Mac, Opera/Mac, and IE5/Mac, but not in IE6/Windows.

Here's the javascript:

<!----- JAVA ----->
<script type="text/javascript">
<!--
function ReloadTextDiv()
{
var NewText = document.getElementById("dynamictext").value;
splitText = NewText.split(/\n\n/).join("</p><p>");
splitText = splitText.split(/\n/).join("<br />");
var DivElement = document.getElementById("textdisplay");
if (splitText == '') {
DivElement.innerHTML = '<p>Start typing to preview your
comment...</p>';
} else {
DivElement.innerHTML = '<p>' + splitText + '</p>';
}
}
//-->
</script>
<!----- JAVA ----->

Here's the HTML that calls it:

<!----- HTML ----->
<p>
<textarea name="comment" id="dynamictext" name="dynamictext"
rows="12" cols="60" onkeyup="ReloadTextDiv();">{comment}</textarea>
</p>

<br/>
<br/>

<div id="comment_container">
<div id="comment_header">
<h1>Live Preview:</h1>
</div>

<div id="comment_content">
<p><span id="textdisplay">Start typing to preview your
comment...</span></p>
</div>
</div>
<!----- HTML ----->

Just in case it's relevant, here's the CSS:

<!----- CSS ----->
#comment_content
{
border: 0;}

div#comment_container{width:95%;margin: 0 auto;background:
#E7E7E7;text-align:left; font-size: 12px; min-height: 127px;}
#comment_container img {border: 0;}

div#comment_header{margin-bottom: 20px;text-align:right;}
#comment_header h1{font-size: 120%;margin:0;padding: 0
5px;background: #9DADC6;color: #FFF; font-size: 12px;}
#comment_container p{margin:0;padding-bottom:0.7em;}
<!----- CSS ----->
How can I make this Javascript work on IE6? Thanks very much in advance to all for any info.
-Vik


Just a tip: you'll get better answers if you post a usable test case,
rather than a mishmash of document pieces.

You're writing badly-formed HTML, nesting a block-level element (p)
inside an inline one (span). Use a div instead (or another p).

Could just replace those carriage returns with <br>s. ie/win uses
'\r\n' for them btw.

Jul 23 '05 #2
Just another bit...whitespace will be compressed unless you replace it
with unicode whitespace:

var NewText = document.getElementById("dynamictext").value;
var splitText = NewText.replace(/\r?\n/g, '<br>').replace(/\s/g,
'\u00A0');

Jul 23 '05 #3
"RobB" <fe******@hotmail.com> writes:
Vik Rubenfeld wrote: ....
Here's the javascript:

<!----- JAVA ----->
That's confuzing! Javascript and Java are two different languages.

<textarea name="comment" id="dynamictext" name="dynamictext"
rows="12" cols="60" onkeyup="ReloadTextDiv();">{comment}</textarea>
It would be more efficient to pass the content of the textarea directly
from here, i.e.,
onkeyup="ReloadTextDiv(this.value);"

Then you save an element lookup.
<div id="comment_content">
<p><span id="textdisplay">Start typing to preview your
comment...</span></p>
</div>
</div>

Just a tip: you'll get better answers if you post a usable test case,
rather than a mishmash of document pieces.
Hear, hear. Although pasting the entire post into an HTML page did give
a page that exhibits the problem.
You're writing badly-formed HTML, nesting a block-level element (p)
inside an inline one (span). Use a div instead (or another p).


No, a div. You can't nest p-elements either, and incorrect nesting is
what is causing the problem.
Who would have thunk, IE balking at incorrect HTML that other browsers
accept.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4
You guys rock. Taking out the nested <p> fixed it. Thanks!
Jul 23 '05 #5
Lasse Reichstein Nielsen wrote:
"RobB" <fe******@hotmail.com> writes:
Vik Rubenfeld wrote:
Here's the javascript:

<!----- JAVA ----->
That's confuzing! Javascript and Java are two different languages.
More, comments within SGML declarations are delimited with `--'. The
ambiguity introduced by a number of adjacent `-' that is not a multiple
of four make this invalid markup. Consequential, Mozilla/5.0 in Standards
Compliance Mode will ignore the following content, while Mozilla/5.0 in
Quirks Mode and IE will not.
You're writing badly-formed HTML, nesting a block-level element (p)
inside an inline one (span). Use a div instead (or another p).


No, a div. You can't nest p-elements either, and incorrect nesting is
what is causing the problem.

Who would have thunk, IE balking at incorrect HTML that other browsers

^^^^^
Drink, drank, drunk -- think, thank, thunk? :)
accept.

PointedEars
Jul 23 '05 #6

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

Similar topics

13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
6
by: Andy Fish | last post by:
Hi, I want to use an anchor tag to invoke some javascript and I've read that it's bad form to use <a href="javascript:foo()"> I've read endless usenet posts and hint sites on the net, they all...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
15
by: Mel | last post by:
if you know of dynamic expandable folder using CSS and display function, please drop me a note Yours, Mel
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
1
by: richardscheff | last post by:
Video selector works for IE but not other browsers. for not IE <object ID='Player' data="video/dodgeball.wmv" type="video/x-ms-wmv" width="320" height="280"> <param name="filename"...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.