Print Page | Close Window

document.write - external css

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10440
Printed Date: 31 March 2026 at 5:51pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: document.write - external css
Posted By: Lucent
Subject: document.write - external css
Date Posted: 14 May 2004 at 4:31pm

how can I use the external style sheet instead?

  document.write("<FONT FACE='Arial, Helvetica, sans-serif' SIZE='1' COLOR='black'>")
  document.write("Currently - " + year + " / " + month + " / " + day + "&nbsp;" + "&nbsp;" +  "&nbsp;" + curTime + " US Central Time")
  document.write("</FONT>")




Replies:
Posted By: Semikolon
Date Posted: 14 May 2004 at 5:31pm
this isn't related to ASP, but I'll help you anyways

start with the tag you want styled. in this case <font>
in your stylesheet, create a class called for example DateTime by adding .DateTime { attributes } in your stylesheet.
in the font tag add class="DateTime" and thats it..

you can also use the span tag instead of the font tag.


Posted By: dpyers
Date Posted: 14 May 2004 at 5:54pm

It's like Semikolon said, but you can get rid of the deprecated font tag altogether. Put something like this in your style sheet

.DateTime  {
    background-color: "FFFFFF";
    font-size:  small;
    font-family: "Arial", "Helvetica", "sans-serif" ; 
    color: "#000000";
]

You can use this class in any text container tag

<div class="DateTime">
<span class="DateTime">
<p class="DateTime">



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Lucent
Date Posted: 15 May 2004 at 4:16pm

Like this? But all the words disappeared

document.write("<div class="DateTime">")
  document.write("Currently - " + year + " / " + month + " / " + day + "&nbsp;" + "&nbsp;" +  "&nbsp;" + curTime + " US Central Time")
  document.write("</div>")



Posted By: Semikolon
Date Posted: 15 May 2004 at 4:25pm
what's your CSS?


Posted By: Lucent
Date Posted: 15 May 2004 at 8:53pm

It is an external CSS which is also connected to the document

document.write("<div class="mystyle">")
document.write("Currently - " + year + " / " + month + " / " + day + "&nbsp;" + "&nbsp;" +  "&nbsp;" + curTime + " US Central Time")
document.write("</div>")

This is what I did, and the words disappeared. I'm pretty sure the CSS is attached because I use it else where on the same document.

Thank you for trying to help me



Posted By: Semikolon
Date Posted: 16 May 2004 at 5:16am
so what IS the CSS you are using then? the style formatting in your CSS class is probably the problem


Posted By: dpyers
Date Posted: 16 May 2004 at 1:42pm

If you can see the date by left-click-drag over the area where it's supposed to be, the problem is likely to be with the sequence of your css statements, or you reversed the fg, bg colors.

If you don't see it, the problem is with the document.write or the conditions leading up to it.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Lucent
Date Posted: 16 May 2004 at 7:13pm

what is IS? if you mean the style that would be just simple 10 px arial black font. I use it else where on the some document, so it would match with rest of the document.

I tried to select the words, but there is just simiply nothing there, so it shouldn't be the font color issue.

The reason why I want this in CSS is because it won't change the font size when viewers change the text size in the browser window.

Anyone knows how to do make this work?

The actual working script is this

-------------------------------------

<SCRIPT language=JavaScript>

<!-- 
  var today = new Date()
  var month = today.getMonth()+1
  var year = today.getYear()
  var day = today.getDate()
  if(day<10) day = "0" + day
  if(month<10) month= "0" + month
  if(year<1000) year+=1900

  var TimezoneOffset = -5 
  var localTime = new Date()
  var ms = localTime.getTime()
  + (localTime.getTimezoneOffset() * 60000)
  + TimezoneOffset * 3600000
  var time =  new Date(ms)
  var hour = time.getHours()
  var minute = time.getMinutes()
  var second = time.getSeconds()
  var curTime = "" + ((hour > 12) ? hour - 12 : hour)
  if(hour==0) curTime = "12"
  curTime += ((minute < 10) ? ":0" : ":") + minute
  curTime += (hour >= 12) ? "pm" : "am"
  document.write("<FONT FACE='Arial, Helvetica, sans-serif' SIZE='1' COLOR='black'>")
  document.write("Currently - " + year + " / " + month + " / " + day + "&nbsp;" + "&nbsp;" +  "&nbsp;" + curTime + " US Central Time")
  document.write("</FONT>")
//-->
</SCRIPT>

------------------------------

And, this is the inline style that I did that doesn't work. If the inline style works, it shouldn't be too hard to do the external.

-----------------------------------------

<SCRIPT language=JavaScript>
<!-- 
  var today = new Date()
  var month = today.getMonth()+1
  var year = today.getYear()
  var day = today.getDate()
  if(day<10) day = "0" + day
  if(month<10) month= "0" + month
  if(year<1000) year+=1900

  var TimezoneOffset = -5 
  var localTime = new Date()
  var ms = localTime.getTime()
  + (localTime.getTimezoneOffset() * 60000)
  + TimezoneOffset * 3600000
  var time =  new Date(ms)
  var hour = time.getHours()
  var minute = time.getMinutes()
  var second = time.getSeconds()
  var curTime = "" + ((hour > 12) ? hour - 12 : hour)
  if(hour==0) curTime = "12"
  curTime += ((minute < 10) ? ":0" : ":") + minute
  curTime += (hour >= 12) ? "pm" : "am"
  document.write("<p style="font-family: arial; font-size: 20px; color: black">")
  document.write("Currently - " + year + " / " + month + " / " + day + "&nbsp;" + "&nbsp;" +  "&nbsp;" + curTime + " US Central Time")
  document.write("</p>")
//-->
</script>

--------------------------------------



Posted By: dpyers
Date Posted: 16 May 2004 at 8:43pm

What Semikilon was asking is that you post the code in the external style sheet.

If you left-click0drag over the area where the code's supposed to be and don't see anything highlighted, it's because there's nothing there. What to you see in the html when you view source? Have you tried it without the first and third document.write statements?



-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net