CSS and JavaScript

  • diamondneil
  • Newbie
  • Newbie
  • diamondneil
  • Posts: 8

Post 3+ Months Ago

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

Post 3+ Months Ago

  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

Why would you want to? Why not just put it in the HTML? What's your goal?
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1853

Post 3+ Months Ago

You can't.
  • AHaz
  • Graduate
  • Graduate
  • User avatar
  • Posts: 144
  • Loc: New York

Post 3+ Months Ago

lol directly to the point
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

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.
  • diamondneil
  • Newbie
  • Newbie
  • diamondneil
  • Posts: 8

Post 3+ Months Ago

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
  • Posts: 1853

Post 3+ Months Ago

"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
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

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.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 52 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.