Solved

jquery get background position

Posted on 2011-03-03
3
714 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
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 …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

690 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