Jump to content

Recommended Posts

hi, I have a problem to use the css style inside the javascript:
I am using style inside my code as follows:
[!--coloro:#339999--][span style=\"color:#339999\"][!--/coloro--]<html>
<head>
<title>LTU Computer Science Forum</title>
<style type="text/css">

TABLE,TR,TD
{
background: transparent;
color: #ff00cc;
background-color: #000000;
}

TABLE
{
width: 100%;

}
</style>
<script language="JavaScript">

function loading()
{

document.write('<img src="LTULogo.jpg" width="974" height="72"/>');

var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("forums.xml");
var doc=xmlDoc.documentElement;
for(var i=0; i<doc.childNodes.length; i++)
display(doc.childNodes(i));
}
function display(cat)
{
document.write('<TABLE cellspacing="1" ><TR><TH COLSPAN="3">'+cat.getAttribute("NAME")+'</TH></TR>');
document.write('<TR><TD>Forum</TD><TD>Topics</TD><TD>Replies</TD></TR>');
for(var j=0;j<cat.childNodes.length;j++)
{var node=cat.childNodes(j);
document.write('<TR><TD>'+node.childNodes(0).firstChild.text+'<br>'+node.childNodes(1).firstChild.text+'</TD><TD>'+node.childNodes(2).firstChild.text+'</TD><TD>'+node.childNodes(3).firstChild.text+'</TD></TR>');

}
document.write('</TABLE>');
}
</script>
</head>
<body onload="loading()">


</body>
</html>[!--colorc--][/span][!--/colorc--]
since I'm using xml Dom so I'm obliged to put the table inside the javascript,
this thing makes the style not working for the table
Does any body know why and how to make it working?
Link to comment
https://forums.phpfreaks.com/topic/7572-css-inside-javascript/
Share on other sites

  • 2 weeks later...
when you use document.write, it clears whatever is on the screen, and writes that on the page. basically you lose you CSS, and everything else that you don't rewrite. Try putting an element on your page such as <div id="content"></div>, and then doing:

document.getElementById("content").innerHTML = "<Table> your table stuff here or whatever";
Link to comment
https://forums.phpfreaks.com/topic/7572-css-inside-javascript/#findComment-31286
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.