I want to know if there was a way to make sure an image was loaded when loading it outside Preload. I sometimes get “Uncaught ReferenceError: loadImage is not defined” and sometimes it loads. It doesnt seem to be predictable. The reason why I need to load outside preload is because I am creating a “preview art on your wall” module where clients load pictures of their wall at runtime in a product page via a “upload image” button in the page. They can change their wall as they please.
You can call preload, by just doing preload(); anywhere. So I guess in your situation you'd just run preload(); when someone uploads a file, you can always add code in preload but try avoiding it.
Related
In one of our projects users get an error "CKEditor is undefined" from time to time if they working with IE for quite some time and than load an XPage with the CKEditor. The error occurs direct after loading the page before the user can interact with it.
It looks like there might be a problem with caching. With a fresh start of IE the problems goes away.
CKEditor is an object to access the CKEditor on the page. So I guess the browser try to call a method but the object has not been loaded yet.
Has anybody experienced the same problem? Maybe also a solution?
I am developing a web app/message board in AJAX. Ive come to the part where I need to decide how to display threads.
Should I refresh a completely new page for each thread? Or load it via AJAX. Obviously, I want each thread to be crawlable, linkable, and saveable as a favorite in your browser.
Then I saw USAToday's website (www.usatoday.com/news). Its very interesting how they load the page through a popup window, change the URI, and keep the data in the background.
This is exactly what I want, but I don't know what they are doing.
Can anyone else decipher this or lead me down the right path?
My impeccable googling skills has led me to believe that the answer lies in pushState.
http://www.seomoz.org/blog/create-crawlable-link-friendly-ajax-websites-using-pushstate
Essentially, it appears they are...
using the HREF of the provided link to change the URI via pushState.
using AJAX to load the contents of the page accessed via the link.
on close, they most likely use data from the newly loaded page to figure out what section its was under(sports, entertainment, etc), and reload that page.
I am coding a website for a client and they requested that because they have so many sidebar pages under one parent, that when the page link is clicked, it loads in the same area every time without the page reloading. They also requested that the URL changes on reload and that you can visit each page by going to that specific url. Unfortunately, I don't know how to do this. I have found a lot of tutorials and snippets that are half way there but they don't offer the exact functionality.
For example, if you go here: http://lookseewatch.com/independentinsurance/commercial-insurance/
You'll see a long sidebar of different types of commercial insurance they offer. When you click on "Automobile," or any link for that matter, the page should be loaded into the div area on the right of the sidebar. The url then should change to reflect this change to http://lookseewatch.com/independentinsurance/commercial-insurance/automobile/. All of these pages are separate and dynamic in Wordpress.
Can anyone offer me some assistance? This is currently how the sidebar is being generated:
wp_list_pages('title_li=&child_of='.$post->ID.'');
Let me know if you need any other code from me or have any questions about the functionality.
Thank you!
This is kinda complicated. There are a lot of ways of catching user events, stopping default behavior and running custom code over it. For exemple, you can listen to anchor clicks and return 0 to not load their links.
But if you change URL in browser address bar, as long as I know, a JS can't control it, because it's outside of a webpage domain, and controling browser components from an external webpage would open a lot of security flaws.
This looks like they wanna avoid banners loading to count less hits :P If performance is the issue, first of all you can use a cache plugin, that will store in HD all DB queries, and use those files in future pageloads instead of making new queries.
You can also build a full sidebar into a PHP variable, cache it in HD and read from there, instead of building the whole code everytime. It will be like adding static HTML snippet.
This can be done with a technique called pushstate combined with AJAX. There's a great jQuery plugin that's called PJAX that implements this. http://pjax.heroku.com/
I have just published a plugin called WP-PJAX that makes to whole wordpress site PJAX driven. I'm not sure if this solves your problem, but it might be something for you.
https://github.com/pelmered/wp-pjax
I'm using a custom written auto uploader to import images from users to Amazon S3. I'm building up a parallel image library in my database, so I know what images I can access on S3 to not waste any http-requests.
However, my uploader sometimes throws errors (e.g. source image missing) and although I'm validating, I'm sometimes ending up with entries in my media table and no matching image on S3.
To correct these, I'm thinking of creating a cfthread/cfschedule which clears my image database from faulty entries. What I'm not sure is how to capture 404 responses. Right now I'm having this on a page:
<img src="#variables.imageSrc#" alt="#some alt#" title="#some title#" class="ui-li-thumb ui-corner-all" />
which tries to load the image and returns a 404 if not successful.
Question
How would I capture this 404? I don't want to put anything in the markup, so I assume this should go to onrequestend or another Coldfusion event being monitored in my application.cfc. If so, is there an easy way to identify image request, because I would not want to run a big routine on every applicationr request.
Thanks for insights!
EDIT:
I don't think running isDefined on every image before displaying it is feasable, because it will be a double request to S3 and there is a lot of images. I want to take the 404 and then clean up my database, so next time the image will not be accessed anymore.
If you don't want to use cfhttp and test each image like Matt suggested, why not trigger an ajax call from the browser using the onError handler of the img tag. Something like this but instead of showing a custom graphic, trigger your ajax to set your flag, or maybe even delete the image since it's happening invisible to the user. jQuery/JavaScript to replace broken images
More info on Image onerror Event
I'm curious to see how you would use isdefined on an image. From your code posted isdefined("variables.imageSrc") wouldn't help you much.
If you're running a scheduled task to do this, why not use cfhttp to perform a GET request on the image asset? You can then check the status code in the response to validate the file existence on the server, and then update the database accordingly.
I need some help? Anyone experience this problem before with IE8 FLASH bug? Can not get this to work on all subsequent refresh to the flash. I have a flash piece which simply renders only on the first initial load. After that, if i refresh or visit the page, it does not load correctly. It seems I am having this problem with the swf only on subsequent loading of the page or whenever a refresh happens. Can you offer any ideas or services to help?
I have seen, on a number of occasions, issues like this occurring due to logical errors with pre-loaders.
Do you have a pre-loader?
If you do, how is it determining if the movie is loaded? Are you expecting a particular event to fire, which might have fired before you listen for it? Can you test to see if the movie is already loaded, before going into the preloader?
Hopefully you have a preloader... otherwise this answer is useless.