www.webdeveloper.com
Results 1 to 4 of 4

Thread: onclick that loads image

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    18

    onclick that loads image

    Guys,

    I need some help. I am trying to figure out how to create a function that has an onclick that when the link is clicked, the function will load an image. This is basically a tracking pixel for third party tracking. Its a request from the client.

    The code that the onclick will go on is below:

    HTML Code:
    <a href="tel://1-888-123-4563" onClick="load(''); return false;" class="link">Call (888) 123-4563Now To Order<sup>&dagger;</sup></a>

    thanks for the help.

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,773
    You can create an image and append it to the document:
    Code:
    function load(url) {
    	if (!load.images) {
    		load.images = document.createElement("div");
    		load.images.style.display = "none";
    		document.body.appendChild(load.images);
    	}
    
    	var image = document.createElement("img");
    	image.src = url;
    	load.images.appendChild(image);
    	image = null;
    }
    
    load.images = null;

  3. #3
    Join Date
    Aug 2011
    Posts
    18
    But this isn't controlled by an onclick event set inside of the anchor tag, right?

  4. #4
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,773

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles