Solved

jquery get background position

Posted on 2011-03-03
3
713 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 39

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

726 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