CSS and JavaScript

  • diamondneil
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Aug 20, 2004
  • Posts: 8
  • Status: Offline

Post September 14th, 2004, 12:16 pm

Does anyone know of a way in which you can embed Javascript within a CSS file?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 14th, 2004, 12:16 pm

  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post September 14th, 2004, 4:00 pm

Why would you want to? Why not just put it in the HTML? What's your goal?
- dM
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Aug 07, 2004
  • Posts: 1853
  • Status: Offline

Post September 14th, 2004, 7:10 pm

You can't.
  • AHaz
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 20, 2004
  • Posts: 144
  • Loc: New York
  • Status: Offline

Post September 14th, 2004, 8:30 pm

lol directly to the point
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Mar 24, 2004
  • Posts: 1855
  • Loc: Uk
  • Status: Offline

Post September 15th, 2004, 1:31 am

well you kinda can for IE, but it's a waste of time as it will only work on IE. Maybe if you give us more information on what you are trying to acheive, we might be able to give you a better solution.
CSS website design tutorials
  • diamondneil
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Aug 20, 2004
  • Posts: 8
  • Status: Offline

Post September 17th, 2004, 4:31 pm

because im trying to set the top: property of a layer that is based on the size of another div that is dynamic. I take advantage of the DOM to reference this, but obviously i have to place this code outside of the stylesheet, which kills a lot of the benefits of CSS-P
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Aug 07, 2004
  • Posts: 1853
  • Status: Offline

Post September 17th, 2004, 6:01 pm

"Layer"? What the fleck is a "layer"? All this dreamweaverspeak is giving me shivers...

~spasm spasm~

I remember trying to use javascript to do:
Code: [ Select ]
document.write('<style type="text/css">\n');
document.write(' body {\n');
document.write('  background: ');
/* well, you get the idea. */
document.write('<\/style>');
  1. document.write('<style type="text/css">\n');
  2. document.write(' body {\n');
  3. document.write('  background: ');
  4. /* well, you get the idea. */
  5. document.write('<\/style>');


If I remember correctly, it worked.

I am guessing that you are trying to do some silly feature for no reason, though. How would this help your Web site?
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Mar 24, 2004
  • Posts: 1855
  • Loc: Uk
  • Status: Offline

Post September 18th, 2004, 12:32 am

When you say " based on the size of another div" do you mean you want it sitting underneath the other div, regardless of the amount of content in the other div? That is what it sounds like to me, but forgive me if I'm wrong. In which case the best way to go is to stop using absolute positioning. It really is quite limiting. Floating is a much better option.

Alternatively, you could try a container with padding-bottom of x pixcels and then use the bottom property (rather than top) for positioning the div. X pixcels would be the height of the lower div.

As for using javascript in a page layout. NO! It means that your page will break for 10% of users. Or maybe just 5%. Either way that is a significant proportion that should not be ignored. Ther is almost certainly a way to do what you want without javascript.
CSS website design tutorials

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 143 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.