[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to update an image src without JavaScript?

Posted on 2007-10-04
6
Medium Priority
?
979 Views
Last Modified: 2013-11-19
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?
0
Comment
Question by:InsertCleverName
6 Comments
 
LVL 1

Accepted Solution

by:
stevenlevithan earned 375 total points
ID: 20018989
The short answer is no, you can't. To dynamically change an image element's src attribute after the page loads, you have to use some sort of scripting language, such as JavaScript or VBScript.

If you explain more about what you're trying to do however, perhaps someone can suggest an alternative implementation.

Note that you can do certain dynamic things using just CSS. For example, IE7, Firefox, and many other browsers support the CSS :hover, :active, and :focus pseudo-classes, which you could use to change the background-image style attribute, for example.
0
 
LVL 5

Expert Comment

by:siva_siva
ID: 20021321
Using AJAX you will update the image but AJAX is also a script function..
0
 
LVL 1

Expert Comment

by:stevenlevithan
ID: 20021392
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:InsertCleverName
ID: 20030361
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?
0
 

Author Comment

by:InsertCleverName
ID: 20030377
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.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20045129
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
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question