/    Sign up×
Community /Pin to ProfileBookmark

Trouble changing the float property of the style object

I’m attempting to change the CSS float property of an element dynamically using Javascript. Since “float” is a reserved word there, I’ve been using

[CODE]element.style.cssFloat = “left”;[/CODE]

This works fine in Firefox, but lo and behold, when I test in IE, the property seems to get ignored. Does IE use a different property name for a float than everyone else does? If so, what is that property name? Or am I totally barking up the wrong tree here?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzOct 14.2005 — element.style.float should work in both browsers, since float is a property of style.
Copy linkTweet thisAlerts:
@Orc_ScorcherOct 15.2005 — Microsoft has renamed this to 'styleFloat'. See http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/float.asp

Cross browser solution:element.style.cssFloat = element.style.styleFloat = "left"
Copy linkTweet thisAlerts:
@KravvitzOct 15.2005 — I was wrong. Apparently I haven't tried to change the float property through the style object before.

Firefox, Netscape 6+, and other Mozilla browsers support cssFloat

IE4+ supports styleFloat

Opera seems to support cssFloat and styleFloat
Copy linkTweet thisAlerts:
@FrankenrhythmauthorOct 17.2005 — Thanks, guys. styleFloat is doing the job nicely. The resource I was using for reference had a property named floatStyle listed, but obviously that wasn't working.

Again, thanks for taking the time to help me out.
×

Success!

Help @Frankenrhythm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...