Any javascript to load an image

i have been given some conversion tracking code like so…

<img width=“1” height=“1” src=“”>

but have been told the website i work on will only use javascript tracking code.

my question is, is there a way of having a piece of javascript code do the same job as this code?

i am guessing if the javascript can load this image on the page some how it will track the conversions… i am hoping this is possible and any pointers would be great.

I’m not familiar with what that code does, but I don’t see why you would need to us JavaScript to include it for it to work. Have you tried adding it to your page to see if it works?

If the page just tracks user visits and stats, I would recommended using Google Analytics instead.

hi unfortunately i can’t use google and can’t add this to the site. i am advertising with some other company and they only have this way to do the conversion tracking…

<img width=“1” height=“1” src=“”>

all this does is loads an image on the page and so tracks conversions… thats all of the code… its very small and simple but i can’t use it.

this is an example of javascript tracking…

<script src=“” type=“text/javascript”>
<script type=“text/javascript”>

just need to know if it is possible to load and image using javascript so i can get around this problem?

Well I’m not really a JavaScript expert, but I would think that if all you need to do is to load the image so that the other site can register that it was loaded, then you could probably either use

document.write('<img width="1" height="1" src="" />');

to write the image in or maybe even use an image preload script to load the image without displaying it.

Don’t use document.write, it’s deprecated. You can do this:

var img = document.createElement('img');
img.height = img.width = 1;
img.src = '';

I’m assuming you have some sort of wrapper there - change that to suit your code. Put the code at the bottom of the body, or if you already have something being loaded onload, stick it in there.

hi thanks i will try them… i don’t have a wrapper but hoping this will just work as is… i am new to javascript but guess it will be…

<script type=“text/javascript”>
var img = document.createElement(‘img’);
img.height = img.width = 1;
img.src = ‘’;

thanks again…