• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

feature testing - float property using javascript - IE, Firefox - cssFloat, styleFloat

 
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

I am trying to float divs left and right by setting the css float property using javascript.

In standard browsers the W3C's elem.style.cssFloat does this fine, however in IE one needs to use elem.style.styleFloat which does not work standard browsers.

I am having trouble feature testing using javascript though, with the code below registering true for both tests in both browsers.



I have also some variants of this.

Does anybody have any better ideas for testing?

Thanks

Marten

 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jQuery has flags that detect this for you. And also, behind the scenes, jQuery just does the right thing so you don't even have to worry about it.

I'd check it out.
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear

I have a key requirement that the float property be set programatically, depending on runtime conditions. Therefore having it behind the scenes and out of 'worries' way is problematic.

I suppose I could hunt through the JQuery framework and see how it is done there,

So I am still open to further javascript suggestions on this....
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at your if statements

Reason you are not using
elem.style.float = "left";

I have no clue what the difference between cssFloat and float is.

Eric
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
by way of closure

My solution was to create two css rules as such


and then in my code just added the classname to the required elements as such



not satisfactory, but it worked across Opera, FF and IE;this feature was already a hack around an IE problem

checked out JQuery and it looks good, but would add to my learning curve - I am one shot or one application developer.

It is difficult to choose a javascript framework, I currently use DOJO to provide a rich text editor, color palette, and drag and drop. To learn another one is a big call for me.

Thanks
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic