Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting javascript check for browser within a table

Status
Not open for further replies.

rams0619

Programmer
Aug 1, 2005
5
US
hi all

I have a table which is aligned properly in firefox bt not aligned properly in ie, so i want to include this javascript
<script language="JavaScript"
type="text/JavaScript">
if(navigator.appName == "Microsoft Internet Explorer")
{


And place an additional td so the text is aligned in IE. bt how do i insert that within this code?

<table width="500" border="0" cellpadding="0" cellspacing="0">

<tr>

<td valign="top">

<!-- the javascript has to be inserted here -->

<!-- iff condition is true then enter create the below column-->

<td valign="top" width="185">&nbsp;

</td>

</td>

</tr>

</table>

Is there another better alternative to do this?

thanks,
rams
 
Is there another better alternative to do this?
There most certainly is... and it's going to be (relatively) painless!

Using CSS we can manage most things nowadays. If you could post the HTML (and any related CSS styles) for your table -- better still a link to a page online... then we can come up with a solution that doesn't require you resort to using Javascript for this problem.

Now... what you ask for is indeed dead easy to do in Javascript... I just reckon you would be better off seeking a CSS solution :)

Code:
<table width="500" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<script type="text/javascript">if (navigator.userAgent.indexOf('Microsoft')>-1) document.write('</td>\n<td valign="top" width="185">&nbsp;</td>');</script>
</td>
</tr>
</table>
Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Thanks!

I wld prefer using a javascript for this. I tried what u sent bt it doesnt work...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top