Solved

jquery get background position

Posted on 2011-03-03
3
709 Views
Last Modified: 2012-05-11
Good Afternoon All,

I have a problem with some jquery/javascript that I am trying to write.  This works fine in FF but not in IE.  Imagine that.

some background - I am pasing a function 4 parameters, all strings.  noteid, marLeft, marTop, direction.

I am getting the last two characters from the noteid and assigning them to a pageid.  

I am then trying to get the background-position that is currently assigned to the pageid.  I am using:
var pgBkgd = $("#"+pageid).css('background-position');

in firefox I get something like 0px 80px
in IE I get undefined.

Can anyone help me out here?

Thanks!
Rose

0
Comment
Question by:rdurban
3 Comments
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 35032229
I think it should be .style(background-position) instead of .CSS

Just off the top of my head
0
 
LVL 6

Accepted Solution

by:
GregArnott earned 500 total points
ID: 35032573
IE can be picky when it comes to background values.

You'll get the 2 values independently by using:
.css('background-position-x')
.css('background-position-y')

Unfortunately, FF doesn't like this separation of values.
0
 

Author Closing Comment

by:rdurban
ID: 35037627
what we ended up using was:

if($.browser.msie) {
            var bkgdX = $("#"+pageid).css('background-position-x');
            var bkgdY = $("#"+pageid).css('background-position-y');
            var pageBkgd = bkgdX + ' ' + bkgdY;
      } else {
            var pageBkgd = $("#"+pageid).css('background-position');
      }
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now