Link to home
Create AccountLog in
Avatar of InsertCleverName
InsertCleverName

asked on

How to update an image src without JavaScript?

I've implemented 1x1 pixel tracking by adding an onclick event to all links - the onclick event updates a 1x1 pixel.  My question is:

can I update a loaded image's src without javascript?
ASKER CERTIFIED SOLUTION
Avatar of stevenlevithan
stevenlevithan

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Using AJAX you will update the image but AJAX is also a script function..
Avatar of stevenlevithan
stevenlevithan

Ajax, which stands for Asynchronous JavaScript and XML / XMLHttpRequest is not a scripting language at all, but merely a technique or collection of technologies. You can't technically use Ajax to update the page... You use XMLHttpRequest to exchange data asynchronously with the web server, and JavaScript to process the response and update the DOM.
Avatar of InsertCleverName

ASKER

Hi,

Thanks for the comments.  I'm trying to update a 1x1 pixel, that belongs to another site, when someone clicks on certain links on my site and then send the clicker to the URL associated with the link.  This works fine, but I see in my logs that ~5-10% of clicks aren't updating the pixel and I assume the users have JavaScript disabled.

Sounds like I have to sync with the owner of the 1x1 pixel and send them a final redirect URL. So a click on my site first redirects to the address the 1x1 pixel uses currently and then the address at the 1x1 pixel will redirect to the final URL I provide.

Any other suggestions?
To clarify, each link that updates the 1x1 pixel will update the 1x1 pixel with a unique src/URL.  Each link has a different cost-per-click associated with it and I'm sending the cost-per-click info to the 1x1 pixel.
Avatar of b0lsc0tt
You might want to clarify what you are trying to do and what the issue is.  I am afraid I am still a little confused despite the details you provided.  The first comment by Steve answered your main question.  His follow up on AJAX is right too.

I would add one small thing.  If the link uses onclick (or any event) and not the href attribute then you are dependent on client side script.  On its own that event is nothing without script being called.  If you are getting charged for every click, even if the script isn't working like you think, then Javascript isn't completely disabled.  Nothing would happen at all when Javascript is disabled (assuming the href is just like this href="#").  The issue might really be in some other part of this tracking process.

If you still need help with this then you might want to elaborate on what you need and what is going on.  I hope this info and the questions will help you know what to provide and explain the basics of what is happening.  You really did get the answer in the first comment so if you want to start a new one for a follow up issue then you can post the URL of that question here.

Let me know if you have a question or need more info.

bol