Why would the src attribute on this html img tag result in a penalty for your abp-3 website?

Consider the following code :

<img src="//website.com/Page/1"/>

"1" is a parameter to insert in some table in the "Page" page in website.com. Will the visitor to this page (that contains the code above) cause an execute of the page and insert 1 to the table ? If the page contains some Javascript code. Will it be executes if we visit the page that contains the code above ?

CharlesB

82.4k27 gold badges185 silver badges208 bronze badges

asked Feb 19, 2013 at 9:16

2

A browser, if configured to load and display images, will first check whether it has the document matching URL in its own cache as fresh (by some caching criteria). If not, it will send, via HTTP, a GET request to mysite.com for the resource /Page/1. What happens then is up to the server. It may just pick up an image file from its resources and send it to the browser, or it may generate an image an send it, or it might (instead of or in addition to such things) store or update something in its database, or just a counter in a file, or whatever it has been programmed to do.

If the resource sent by the server is image data, the browser will try to display it. If it happens to be e.g. an HTML document, it will be discarded, and the browser will display the value of the alt attribute instead, or an icon of a broken image, or both.

answered Feb 19, 2013 at 9:35

Jukka K. KorpelaJukka K. Korpela

189k36 gold badges257 silver badges375 bronze badges

When the browser finds this img tag in a visible area (so it should not be hidden with display: none for example), it executes the image as a http request. That's how statistic tracking works, too.

So as it's a regular http request it will execute the server-side code for that URL, which should in return deliver an image (be it just a blank 1x1 gif), so the browser does not report an error.

But keep in mind the browser might cache the image if you visit this page the second time. So either append a random string or timestamp at the end (e.g. //website.com/Page/1?23423412341) or tell the browser with htaccess to not cache it.

answered Feb 19, 2013 at 9:24

acmeacme

14.3k7 gold badges73 silver badges106 bronze badges

Last update on August 19 2022 21:51:12 (UTC/GMT +8 hours)

src

The purpose of the HTML src attribute is to specify a URI for an external file or resource.

Supported elements

HTML src attribute supports frame, iframe, img, input and script elements.

Syntax

<ElementName src="value" >.....</ElementName>

Where ElementName is any supported element.

Type of value

URI.

Value

A URI indicating a file or resource.

Default value

There is not default value of HTML src attribute.

Supported doctypes

HTML 4.01 strict, HTML 4.01 transitional when used with img, input and script elements.

HTML 4.01 frameset when used with the frame, iframe.

Example of HTML src attribute with img element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "//www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Example of HTML src attribute with img element</title> </head> <body> <p><img src="../../images/w3logo5.gif" alt="w3resource logo" /></p> </body> </html>

Result

View this example in a separate browser window

Example of HTML src attribute with img element

Example of HTML src attribute with script element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "//www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Example of HTML src attribute with script element</title> <script type="text/javascript" src="w3r_src_example.js"> </script> </head> <body onload="w3r_src_example()" > <p>This is an example of HTML src attribute with script element.</p> </body> </html>

Result

View this example in a separate browser window

Example of HTML src attribute with script element

Example of HTML src attribute with input element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "//www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Example of HTML src attribute with input element</title> </head> <body> <form name="user_info" action="../../html/html-editor/action_post.php" method="post"> Name :<input type="text" name="name"><br> email :<input type="text" name="email"><br> <input type="image" src="submit.gif" alt="Submit"> </form> </body> </html>

Result

View this example in a separate browser window

Example of HTML src attribute with input element

Example of HTML src attribute with frame element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "//www.w3.org/TR/html4/frameset.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Example of HTML src attribute with frame element</title> </head> <frameset rows="20%,*,20%" > <frame src="header.html" frameborder="1" name="header" title="Header window"> <frame src="content.html" frameborder="0" name="content" title="Content window" marginheight="10"> <frame src="footer.html" frameborder="0" name="footer" title="footer window" marginheight="10"> </frameset> </html>

Result

View this example in a separate browser window

Example of HTML src attribute with frame element

Example of HTML src attribute with iframe element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "//www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Example of HTML src attribute with iframe element</title> </head> <body> <iframe src="../../sql/customer.php" height="100%" width="540" frameborder="1" title="The customer information"> </iframe> </body> </html>

Result

View this example in a separate browser window

Example of HTML src attribute with iframe element

Previous: HTML span attribute
Next: HTML standby attributee

Toplist

Neuester Beitrag

Stichworte