I need to disable an image which I am using in <a "href"> until the page completely loads.
I cannot use document.ready() because I need to disable the the BEFORE the document is ready.
Can someone please help me with this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Define it in your HTML as disabled:
And then on page load re-enable it.
This has the downside of breaking functionality for users without Javascript. The other way to do it is to add a small line of code directly after the button:
…and then re-enable on document.load()
Edit with new info:
Is it an
inputwith type ‘image’? If so, the above will still work. If not, and it’s an<a>tag with an image inside it, I wouldn’t recommend doing what the accepted answer suggests, sorry. Having an image suddenly appear at the end could get quite frustrating or distracting, considering that the page takes so long to load that you need to disable the link. What I’d suggest instead is this:and then in your document.ready function, change the definition of the function:
Alternatively, you could put a check inside the function to see if the page has loaded or not.