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

Document.write headaches

Hey gang,

I'm trying to have a certain piece of html be written into a document
depending on the browser (specifically, Netscape). Anyway, I have the
following INSIDE the html (nested in a table) and wonder if this is
incorrect. Can someone give me some pointers? It's been a while since
I've done any javascripting and this will help so much. Thank you!!

<script language="javascript">
<!-- hide javascript
if (navigator.appName == 'Netscape'){
document.write('<TD align=center height=250><img
src=media/copyright.gif width=260 height=13 alt= border=0>';
}

else {
document.write('<TD align=center><img src=media/copyright.gif
width=260 height=13 alt= border=0>';
}
// done hiding -->
</SCRIPT>
Jul 20 '05 #1
2 3006
"Evertjan." <ex**************@interxnl.net> writes:
<SCRIPT>
<script type="text/javascript">
The type attribute is mandatory in HTML 4+
document.write() needs a closing bracked:
I think that is the original posters problem.
===================

why not do this:

<TD align="center"
<SCRIPT>
if (navigator.appName == 'Netscape')
document.write("height="250px")
</SCRIPT>
Because it is illegal HTML. Script tags are HTML tags, and they must
obey the normal rules for nesting tags. You cannot put a tag *inside*
another tag, only inside the element (between open and close tags).
(And as a side note, script tags are only legal inside the head or
body elements).

Also, you shouldn't add "px" to the height attribute. Preferably you
shouldn't use the HTML height attribute, but use CSS styles instead
(as you say later), or you should just write the number (height="250").
<TD align="center" id="td74">
<img src="media/copyright.gif" width="260px"
height="13px" alt="" border="0">

and later [or <body onload=..]

<SCRIPT>
Type is mandatoty.
if (navigator.appName == 'Netscape')
document.getElementById("td74").height="250px"
The original poster didn't say which Netscape he is after, and this
would break in Netscape 4. Apart from that, I would prefer this
method. The HTML height attribute doesn't use "px".
btw1: it seems more reasonable to set the height of a <tr> than of a <td>
It should work, at least if you use CSS (I am not sure how the HTML
attributes interact with CSS, but proabably reasonably).
The height of a table cell is the maximum of the specified height and what
the contents need. The height of a table row is the maximum of its specified
height and the heights of the cells in that row.
btw2: even better use css:


Absolutely!

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote on 20 aug 2003 in comp.lang.javascript:
Because it is illegal HTML.


You are right. My brain was in serverside mode.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #3

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

Similar topics

1
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
5
by: hijwel | last post by:
<script language="JavaScript"> <!-- document.write('<form name="combo"><select name="example" size="1 onChange="Draw()">'); document.write('<option value=none>Maak je keuze');...
3
by: Ike | last post by:
Can anyone discern why the following code writes the document.write() lines literally? That is, a line like document.write('<CENTER>') should write <CENTER> but instead writes the entire ...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
14
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
11
by: Tony | last post by:
Is it me, or is document.write just about the most abused js function? Maybe, like goto, js would be better without it? Is there any good reason to use it? Because I'm having a hard time seeing...
8
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.