OptimusCrime
OptimusCrime

Reputation: 14863

F5 not fully refreshing my page

I've got a pretty complex webpage which uses alot of Ajax and Javascript. My problem is that this Javascript manipulates the background-picture in a div (scrolling it to the sides). When I hit F5 (mostly in FF) this only causes a "halfway" refresh. The content refreshes, but the background in the div stays in the same position. This causes problems because the offset is calculated wrong (the script thinks the background is at starting-position, but actually, it's moved).

Is there any way of forcing a full refresh to get rid of this problem? I am using jQuery for my Javascript. A workaround would be to check the offset at load, but this would be a pain in the ass to implement at this point.

Any ideas?

EDIT: The picture causing this problem is not loaded using javascript or ajax. It's pure, static html.

Upvotes: 1

Views: 3189

Answers (5)

daveyfaherty
daveyfaherty

Reputation: 4613

Why don't you just reset the state of the background to it's default when the page loads? Is there a reason why that wouldn't work?

$(document).ready(function(){
  // Set whatever value you're changing to make the background move to it's default
  $('.changing-background').css({
    'left' : ?px,
    'background-position' : ?px ?px
    // Whatever you're using

  })
})

Upvotes: 1

Rafay
Rafay

Reputation: 31033

In Mozilla Firefox, Ctrl+Shift+P starts private browsing and nothing gets cached. or you can set cache:false to your ajax requests like

$.ajaxSetup({
cache:false
});

add no-cache

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

further information can be found here

Upvotes: 0

Rohan Patil
Rohan Patil

Reputation: 2348

If you just pressed F5 it will load the contents from the cache.So use " Ctrl+F5 " .It refreshes the browser cache also at the time of reload.

Upvotes: 0

Steve
Steve

Reputation: 3663

Add a unique string to the end of your javascript file path e.g. test.js?nocache=99999999. This will make the browser think it's a non-cached file and download a new copy every time.

It's meaning more data transfer, but unless you want to implement a client side fix I don't think there's much choice here.

Upvotes: 1

Marco Pace
Marco Pace

Reputation: 3870

Try to use "Ctrl + F5", it will force your browser to reload every content in the page.

Upvotes: 3

Related Questions