tags:

views:

50

answers:

3

I am using this code to slide the image down when window is scroled down but nothing is happenning

$('#left_img').css("top",$(window).scrollTop()+"px");




#left_img {
margin:0 0 0 -55px !important;
position:absolute;
top:5px !important;
}

Is it possible to find out how much is height of whole scroll window and then if image reaches certain height then it should stop sliding down

+2  A: 

You need to actually capture the event first.

$(window).scroll(function() { 
    $('#left_img').css("top", $(window).scrollTop()+"px");
});

I don't know much about scrolling and positioning, but if you're not capturing the event, that could be you're problem.

bschaeffer
A: 

I think your javascript doesn't make sense! Why Do you scrolling Image (with javascript/jquery)?

All you need is to set

#imageID
{
    position: fixed;
    left: 20px;
    top: 20px;
}

It will scroll with page. So whats the reason to scrollimage with script?

Nasser Hadjloo
Maybe because some people still have/like to support IE6..?
peirix
come on man, even google do not support IE6 any more, forget about it and create standard code for standard browser.there are alwaye some trick to implement every thing for IE6 but are you serious? I think you need to check some famoud site (PCMag - Times - etc) and check if they are supporting IE6 or not? and thenyou will easily get over IE 6
Nasser Hadjloo
Do you have any clients at all? One of the biggest clients we have at my job is a big and slow company. The employees are all locked down to IE6. So when they ask us to create something for them, we're not going to say we won't support IE6 because "we don't want to". I'd like to see you turn down a high-pay project because the client wants IE6-support. Good luck surviving out there.
peirix
And by the way: Google is NOT someone you should look at for web standards.
peirix
You don't have to support it if you don't want to. You only have to support it in scenario where you'd loose your client/job if you refused.
bschaeffer
@peirix - I think it is better to negotiate with client and tell them truth aboutweb standard and browsers,familier them with Firefox- Opera and newer versions of IE - so that they may accept. it is always a good idea to create standard codes and `satisfy` client. but if you only want to support IE6.0 then you can easily get rid of web standards and just support IE 6.0.
Nasser Hadjloo
I had a project for a man who wanted to create a Perian Website and he need to support IE 6 - 7 - 8 - firefox 3.0 - 3.5 - opera and .... finally the project time expanded from 100 hrs to 170 hrs (so client has to pay for his requests, if so,you have to support and ifnot. itis better to don't get the job in my opinion)
Nasser Hadjloo
Yeah, I'm not saying you should support IE6 _always_, just in those cases where you know the client needs it, or if they ask for it. And let the client know it'll take some extra time, which means it'll cost more for them. Most of us are paid on an hour-to-hour basis, which means you shouldn't drop a project just because it needs to be available in IE6. But if you can persuade your client into changing _their_ browser, all the better!
peirix
A: 

Make it a little bit neater;

$(window).scroll(function(){
       var getbodyt = $(window).scrollTop();
       var getbodyl = $(window).scrollLeft();
       $("#left_img").css({top: getbodyt, left: getbodyl});
    });
joberror