Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / March 2005

Tip: Looking for answers? Try searching our database.

How to: Control "CSS" styles via JScript?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
charliewest - 11 Mar 2005 18:41 GMT
I need to set the background-position of a style in real-time, with onload
event via JScript. Assuming this is possible, can anyone tell me how?

Thanks,
Steve Fulton - 12 Mar 2005 11:58 GMT
> I need to set the background-position of a style in real-time, with onload
> event via JScript. Assuming this is possible, can anyone tell me how?

RTFM.
background-position Attribute | backgroundPosition Property
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/backgroundp
osition.asp


Signature

Steve

We must believe in luck. For how else can we explain the success of
those we don't like? -Jean Cocteau

charliewest - 12 Mar 2005 17:37 GMT
Um... I'm familiar w/ this sample, and read-up a little before posting this
question. I might be way off, but this has nothing to do w/ my question.

The sample doesn't "set" STYLE properites, it simply applies already
hard-coded styles to objects dynamically. Again, I need to calculate the
actual position upon page load and literally set this style property in
real-time.

"En cuanto mas personas conozca, mas me gusta mi pero."
Camilo Jose Cela.

> > I need to set the background-position of a style in real-time, with onload
> > event via JScript. Assuming this is possible, can anyone tell me how?
>
> RTFM.
> background-position Attribute | backgroundPosition Property
> http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/backgroundp
osition.asp
charliewest - 12 Mar 2005 17:51 GMT
oh.. yes... i forgot to write RTFQ. Thanks,

> Um... I'm familiar w/ this sample, and read-up a little before posting this
> question. I might be way off, but this has nothing to do w/ my question.
[quoted text clipped - 13 lines]
> > background-position Attribute | backgroundPosition Property
> > http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/backgroundp
osition.asp
Steve Fulton - 13 Mar 2005 13:37 GMT
[quoting noramlized; sigs trimmed]

>> > > I need to set the background-position of a style in real-time, with onload
>> > > event via JScript. Assuming this is possible, can anyone tell me how?
[quoted text clipped - 11 lines]
>
> oh.. yes... i forgot to write RTFQ. Thanks,

Where in the FQ did you say that you had read up before posting? That
you knew anything about the backgroundPosition property (as opposed
to the (background-position attribute)?

How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html

The second example shows how to change the background position using
the backgroundPosition property. I will concede that the example uses
a hard-coded value; but you never gave any information about how to
calculate the actual position. I apologize for assuming that you knew
how to determine what background position you needed.

<body onload="
  var elem = document.getElementById('someIdYouNegelectedToMention');
  if (someConditionYouNegelectedToMention) {
    var pos = someCalculationYouNegelectedToMention;
  }
  else {
    pos = anAlternateCalculationYouNegelectedToMention;
  }
  elem.style.backgroundPosition = pos;
">

Signature

Steve

An army of sheep led by a lion could easily defeat an army of lions
led by a sheep. -Arab Proverb

Serge Baltic - 12 Mar 2005 19:10 GMT
c> I need to set the background-position of a style in real-time, with
c> onload event via JScript. Assuming this is possible, can anyone tell
c> me how?

See the document.styleSheets property for details.

Something like CSS/workshop/author/dhtml/reference/collections/stylesheets.htm
in MSDN.

Signature

Serge


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.