Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with Document.Write()

0 views
Skip to first unread message

Tommy Carter

unread,
Jun 5, 2000, 3:00:00 AM6/5/00
to
Can anyone tell me why the following HTML/Javascript doesn't work in
Communicator? The colon in the style tag screws it up. It works in IE. I
thought maybe the colon was a special character, so I tried escaping it
with no luck. Anyone know the proper way to write it or a workaround?
I've tried it with three different 4.x versions of Communicator. Thanks,
Tommy.


<html>
<head>
<title>Test</title>
<body>
Some Text Before<br>
<script language="javascript">
document.writeln("<a style='color: #00FF00' href='test.htm'>Link Text
in the Middle</a>");
</script>
<br>Some Text After
</body>
</html>


Martin Honnen

unread,
Jun 5, 2000, 3:00:00 AM6/5/00
to
Use a style class
<HEAD>
<STYLE>
.link { color: #00ff00; }
</STYLE>

<A CLASS="link" ...

--

Martin Honnen
http://javascript.faqts.com/
http://home.t-online.de/home/martin.honnen/jsgoddies.html

Tommy Carter

unread,
Jun 5, 2000, 3:00:00 AM6/5/00
to
After I replied to this the first time, I looked into styles a bit more and
found out how to specify a named style using the tag's ID attribute. That
works for me on both browsers. Thanks for the suggestion. For reference, if
anyone knows why the javascript doesn't work, I'd like to know.

Thanks,
Tommy

Tommy Carter

unread,
Jun 5, 2000, 3:00:00 AM6/5/00
to
I tried that, but it doesn't apply just to the specific layer that I'm working
with. I need for the main document to be normal and a specific layer (a popup
menu) to be formatted differently. If you can tell me how to make it work for
an individual layer only, that will work fine for me. Besides, I'd still like
to know why the javascript code doesn't work.

David A Craig

unread,
Jun 5, 2000, 3:00:00 AM6/5/00
to
Tommy-
Strictly speaking, I think you should reverse your use of single and double
quotes; the double quotes should be around the html attributes, and the single
quotes around the string. That may or may not be your problem, but it's
worth a try.

I've also had some personal trouble with Netscape and document.writeln(). You
might at least check to see if document.write() works for you instead.

David

Martin Honnen

unread,
Jun 6, 2000, 3:00:00 AM6/6/00
to

Tommy Carter wrote:
>
> After I replied to this the first time, I looked into styles a bit more and
> found out how to specify a named style using the tag's ID attribute. That
> works for me on both browsers. Thanks for the suggestion. For reference, if
> anyone knows why the javascript doesn't work, I'd like to know.

NN4 and inline style causes trouble, you don't even need js to get that.
>
> Thanks,

Tommy Carter

unread,
Jun 6, 2000, 3:00:00 AM6/6/00
to
Martin,

I was trying to keep the post short, so I didn't explain fully. I'm using JS to
sniff the browser and write out the appropriate HTML for layering on IE and NS.
Although they both support the DIV tag, NS screws up the positioning. Therefore, I
need a layer tag written out if the browser is NS4+. Also, if the browser is
neither NS4+ or IE4+, the HTML for the popup menu layer doesn't get written out at
all. Part of the HTML for the popup menu is the excerpt that I posted. That's why
I'm using JS to write out a statement that includes the style attributes.

Tommy

Tommy Carter

unread,
Jun 6, 2000, 3:00:00 AM6/6/00
to
David,

I was originally using document.write() with the same problem. I tried switching
the quotes as you suggested with no difference. The colon doesn't appear to be the
real problem. I wrote out the same statement, using a bogus tag instead of the
STYLE tag and it worked fine. It appears to be a problem with NS and inline styles
in CSS format. Thanks for the input.

Tommy

Tommy Carter

unread,
Jun 6, 2000, 3:00:00 AM6/6/00
to
I tried changing the STYLE tag to a bogus tag of CRAP. NS didn't have any problems
writing that out properly. It does appear to be related to inline styles using CSS
format. Thanks for the help.
0 new messages