Solved

jquery get background position

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

809 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