views:

73

answers:

9

So a lead tracking company needs a link to fire and it was in the head tag...will it fire.

<head>
    <img width=1 height=1 src='http://track.searchignite.com/si/CM/Tracking/TransactionTracking.aspx?siclientid=4426&amp;DetailDescription=935626&amp;transactionamount=1&amp;SICustTransType=19172&amp;jscript=0&amp;x10=goog&amp;x9=1&amp;x8=935626&amp;x7=777+665-9999&amp;x6=jones&amp;x5=matt&amp;x4=&amp;x3=Camarillo&amp;x2=Oxnard%2C+CA+Metro+Area&amp;x1=Hidden+Springs&amp;n1=Austin--Bedroom--austin_1_bedroom_apartments-P'&gt;
</head>
+1  A: 

Yes. I tested in FireFox and Chrome and it was requested.

Adam
+4  A: 

It shouldn't. The spec says:

User agents do not generally render elements that appear in the HEAD as content.

See the spec

But browsers can do anything they want to.

Added:

It's a loose area in the spec. Eg a browser could:

  • Render the element
  • Ignore the element
  • Load the image from its server but not render it
  • Or something else

... and the browser would be compliant.

So see what your favorite browsers do and then use the info as you wish...

Larry K
A: 

Web browsers will indeed load the image. I suspect that the placement of it in the head of the document is because the src attribute doesn't load an actual image, so it would appear as a broken image in the web page itself. Since it's in the head, it will be called but not rendered on the page.

In effect, that acts like an asynchronous script call, because the browser will perform a GET request for that image's src attribute's URL while loading the page.

Tim S. Van Haren
+3  A: 

That would depend on the browser. The code is incorrect, and there is no standard for how to handle incorrect code, so it's up to each browser to try to make any sense of it.

I think that most browsers would change to a tag soup mode, and show whatever they can, but some browsers might ignore the image instead.

There is also the matter what the incorrect code does to the rest of the page. If the browser changes how the code is parsed, it may have negative effects on the code that is correct.

Guffa
+1  A: 

Most browsers don't bother about the rules, so it will work. But if you want to be standards compliant, you shouldn't do this. (At least in XHTML, it is invalid to place an <img> tag within <head>.)

casablanca
A: 

Technically yes.. but its much better to just put it in an HTML / JS call..

HTML

<body onload="triggerLink('4426');">

JAVASCRIPT

function triggerLink(var1){
    var receiveReq = getXmlHttpRequestObjectShipping();
    var url= 'http://track.searchignite.com/si/CM/Tracking/TransactionTracking.aspx?siclientid=' + var1;

    if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
        receiveReq.open("POST", url, true);
        receiveReq.onreadystatechange = handleLink; 
        receiveReq.send(null);
    }
}
function handleLink(){
    //Do This when request finished
}

You can add variables to the "tiggerLink" function as well to pass the rest of your URL parameters.

Dutchie432
+1  A: 

I suggest using a <script> tag instead of an <img> tag. Then there is no question whether a browser will request the url. Just be sure it doesn't return anything that could cause a script error.

Ray
A: 

I would be more inclined to use a link to and specify it as stylesheet:

<link rel="stylesheet" type="text/css" src="http://track.searchignite.com/si/CM/Tracking/TransactionTracking.aspx?siclientid=4426&amp;DetailDescription=935626&amp;transactionamount=1&amp;SICustTransType=19172&amp;jscript=0&amp;x10=goog&amp;x9=1&amp;x8=935626&amp;x7=777+665-9999&amp;x6=jones&amp;x5=matt&amp;x4=&amp;x3=Camarillo&amp;x2=Oxnard%2C+CA+Metro+Area&amp;x1=Hidden+Springs&amp;n1=Austin--Bedroom--austin_1_bedroom_apartments-P"&gt;

All should be OK if TransactionTracking.aspx returns empty content.

Sinan Ünür
+1  A: 

Yes, the browser will attempt to load the img resource, but for reasons that aren't immediately obvious.

Assuming this is served as text/html, when the browser's parser sees the <img> element it will believe that it is encountering displayable content and simply infer the </head> and <body> tags (remember, these are optional in HTML), so the <img> is not actually in the head element, but in the body element.

If you use firebug, or another means of inspecting the DOM such as http://software.hixie.ch/utilities/js/live-dom-viewer/, you can see for yourself that this is the case.

Since the img is in body, the browser doesn't see it as different from any normal <img> element.

Alohci