/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Made an image preload function, sometimes it doesn’t work

Hi.
So I am working on building a site for my friend, and when I started working on it, I cam across a roadbump on the JS-enabled site — I made it so it would show a loading screen for the website so it will preload some images (say, like, buttons, logo(s), etc), and when you type in localhost (it runs on my local server) without a hash, it works just fine, and when you reload the page when it DOES have a hash (part of the feature, when you reload a page with a hash, it will read the hash, and show you the content related to the hash (say #main will show you the main page)

I really can’t pinpoint it, so I will dump the entire website JS file, and see if you can find anything that I am doing wrong.
Here are a few screenshots of what happens:

The site when loaded without a hash suffix (note that the hash automatically is placed on load)-
[url]http://i.minus.com/ijHYCX8BZ2DxL.png[/url]
The site when reloaded or loaded WITH a hash suffix-
[url]http://i.minus.com/iCbxKrKVUybdH.png[/url]

And here is the main.js file and a couple of HTML files for your reference to know what the document.getElementById is doing

the main.js, the content/initMain.html and the index.html files –
[url]https://docs.google.com/folder/d/0ByxXyLyaIT3KU2Y0akZCYnptek0/edit[/url]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@TechnicolorauthorOct 12.2012 — Quick edit:

I noticed that the screenshots don't show the address -

the first one without the hash suffix is simply localhost (and on load, it turns into localhost/#main), while the one WITH the hash suffix is localhost/#main
Copy linkTweet thisAlerts:
@TechnicolorauthorOct 16.2012 — Fixed: Basically, on the image preload array, I had images/bg.jpg, which is the background, and at the same time, I had images/bg.jpg for the background in CSS, so in essence, I was sending the request twice.

I just removed the images/bg.jpg from the CSS background section, and it started working again.
×

Success!

Help @Technicolor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...