Baseline Widely available *
HTMLImageElement
æ¥å£æä¾äºç¹å«ç屿§åæ¹æ³ (å¨å¸¸è§ç HTMLElement
ä¹å¤ï¼å®ä¹è½éè¿ç»§æ¿ä½¿ç¨) æ¥æçºµ <img>
å
ç´ çå¸å±åå¾åã
must be a string
ConstructorImage()
Image()
æé å¨ï¼å¸¦æä¸¤ä¸ªå¯éçåæ°ï¼åå«è¡¨ç¤ºèµæºç宽度åé«åº¦ï¼å建äºä¸ä¸ªå°æªè¢«æå
¥ DOM æ ä¸ç HTMLImageElement
å®ä¾ãWhen called without parameters, new Image()
is equivalent to calling document.createElement("img")
.
ä»å®çç¶å
ç´ HTMLElement
ç»§æ¿ç屿§ã
HTMLImageElement.alt
ä¸ä¸ª DOMString
表示 HTML 屿§ alt
ï¼è¡¨æå¾åçåå¤æè¿°å
容ï¼ä¼å¨å¾åæ æ³å è½½æ¶æ¾ç¤ºã
HTMLImageElement.complete
åªè¯»
è¿åä¸ä¸ª Boolean
妿æµè§å¨å·²ç»ä¸è½½å®æ¯ï¼å¹¶ä¸å¾åæ¯åæ¯æçå¾çç±»åãè§£ç çè¿ç¨ä¸æ²¡æåçé误ï¼åè¿å true
ãThat means this value is also true
if the image has no src
value indicating an image to load.
HTMLImageElement.crossOrigin
ä¸ä¸ª DOMString
表示è¿ä¸ª img å
ç´ ç CORS 设置ãåè CORS settings attributesãThis may be null
if CORS is not used.
HTMLImageElement.currentSrc
åªè¯»
è¿åä¸ä¸ª DOMString
表示å è½½å½åæ¾ç¤ºçå¾åç URLã è¿å¯è½ä¼æ¹åï¼å 为å¾åæ¯è°æ´ï¼ç±äºä¸æååçæ¡ä»¶ï¼ç±ä»»ä½ media queries çå°æ¹ã
HTMLImageElement.decoding
An optional DOMString
representing a hint given to the browser on how it should decode the image. If this value is provided, it must be one of the possible permitted values: sync
to decode the image synchronously, async
to decode it asynchronously, or auto
to indicate no preference (which is the default). Read the decoding
page for details on the implications of this property's values.
HTMLImageElement.height
ä¸ä¸ªæ´æ°ï¼è¡¨ç¤º HTML 屿§ height
ï¼è¯´æäºå¾åå¨ CSS åç´ ä¸æ¸²æçé«åº¦ã
HTMLImageElement.isMap
ä¸ä¸ª Boolean
表示 HTML 屿§ ismap
ï¼è¯´æäºå¾åæ¯æä¸ªæå¡å¨ç«¯å¾åæ å°çä¸é¨åãThis is different from a client-side image map, specified using an <img>
element and a corresponding <map>
which contains <area>
elements indicating the clickable areas in the image. The image must be contained within an <a>
element; see the ismap
page for details.
HTMLImageElement.naturalHeight
åªè¯»
è¿åä¸ä¸ªæ´æ°ï¼å¦æå¯ç¨çè¯ï¼è¡¨æå¾åå¨ CSS ä¸åºæçé«åº¦ï¼åä½ä¸ºåç´ ï¼å¦åè¿å 0
ã妿å¾çæ¯ä»¥å
¶åæ¥ç大尿¸²æï¼åæ¤å¼çäºå¾ççé«åº¦ã
HTMLImageElement.naturalWidth
åªè¯»
è¿åä¸ä¸ªæ´æ°ï¼å¦æå¯ç¨çè¯ï¼è¡¨æå¾åå¨ CSS ä¸åºæç宽度ï¼åä½ä¸ºåç´ ï¼å¦åè¿å 0
ã妿å¾çæ¯ä»¥å
¶åæ¥ç大尿¸²æï¼åæ¤å¼çäºå¾çç宽度ã
HTMLImageElement.referrerPolicy
A DOMString
that reflects the referrerpolicy
HTML attribute, which tells the user agent how to decide which referrer to use in order to fetch the image. Read this article for details on the possible values of this string.
HTMLImageElement.sizes
å®éªæ§
A DOMString
reflecting the sizes
HTML attribute. This string specifies a list of comma-separated conditional sizes for the image; that is, for a given viewport size, a particular image size is to be used. Read the documentation on the sizes
page for details on the format of this string.
HTMLImageElement.src
ä¸ä¸ª DOMString
表示 HTML 屿§ src
ï¼å
å«å¾åç宿´ç URLï¼å
å«å¾åçåºç¡ URLã
HTMLImageElement.srcset
å®éªæ§
ä¸ä¸ª DOMString
表示 HTML 屿§ srcset
ï¼å
å«äºåéå¾åå表ï¼ç¨éå·åéï¼',', U+002C COMMA
ï¼ãä¸ä¸ªåéçå¾åæ¯ä¸ä¸ª URL è·çä¸ä¸ª 'w'
表示å¾åçå®½åº¦ï¼æè
ä¸ä¸ª 'x'
表示åç´ å¯åº¦ã
HTMLImageElement.useMap
ä¸ä¸ª DOMString
表示 HTML 屿§ usemap
ï¼å
å«ä¸ä¸ª <map>
å
ç´ ç页颿¬å° URLãThe page-local URL is a pound (hash) symbol (#
) followed by the ID of the <map>
element, such as #my-map-element
. The <map>
in turn contains <area>
elements indicating the clickable areas in the image.
HTMLImageElement.width
ä¸ä¸ªæ´æ°ï¼è¡¨ç¤º HTML 屿§ width
ï¼è¯´æå¾åå¨ CSS åç´ ä¸æ¸²æç宽度ã
HTMLImageElement.x
åªè¯» å®éªæ§
An integer indicating the horizontal offset of the left border edge of the image's CSS layout box relative to the origin of the <html>
element's containing block.
HTMLImageElement.y
åªè¯» å®éªæ§
The integer vertical offset of the top border edge of the image's CSS layout box relative to the origin of the <html>
element's containing block.
HTMLImageElement.align
å·²å¼ç¨
ä¸ä¸ª DOMString
ï¼è¡¨ç¤ºå¾åå¦ä½ä¸å®å¨å´çå
容对é½ãThe possible values are "left"
, "right"
, "justify"
, and "center"
. This is obsolete; you should instead use CSS (such as text-align
, which works with images despite its name) to specify the alignment.
HTMLImageElement.border
å·²å¼ç¨
ä¸ä¸ª DOMString
ï¼è¡¨ç¤ºå¾åè¾¹æ¡çå®½åº¦ãæ¤å±æ§å·²è¢«å¼ç¨ï¼åºè¯¥ç¨ CSS border
屿§æ¥ä»£æ¿å®ã
HTMLImageElement.hspace
å·²å¼ç¨
ä¸ä¸ªæ´æ°å¼ï¼æå®å¾åå·¦å³ççç½ï¼åä½ä¸ºåç´ ã
HTMLImageElement.longDesc
å·²å¼ç¨
ä¸ä¸ª USVString
ï¼specifying the URL at which a long description of the image's contents may be found. This is used to turn the image into a hyperlink automatically. Modern HTML should instead simply place an <img>
inside an <a>
element defining the hyperlink.
HTMLImageElement.lowSrc
å·²å¼ç¨
ä¸ä¸ª USVString
ï¼specifying the URL of a low-quality (but faster to load) version of the same image. This was once used by browsers under constrained network conditions or on slow devices.
HTMLImageElement.name
å·²å¼ç¨
ä¸ä¸ª DOMString
ï¼representing the name of the element.
HTMLImageElement.vspace
å·²å¼ç¨
ä¸ä¸ªæ´æ°å¼ï¼æå®å¾åä¸ä¸ççç½ï¼åä½ä¸ºåç´ ã
ä»å®çç¶å
ç´ HTMLElement
ç»§æ¿çæ¹æ³ã
HTMLImageElement.decode()
Returns a Promise
that resolves when the image is decoded and it's safe to append the image to the DOM. This prevents rendering of the next frame from having to pause to decode the image, as would happen if an undecoded image were added to the DOM.
src
attribute is empty or null
.src
URL is the same as the URL of the page the user is currently on.<img>
element's attributes.If an error occurs while trying to load or render the image, and an onerror
event handler has been configured to handle the error
event, that event handler will get called. This can happen in a number of situations, including:
var img1 = new Image(); // Image æé å¨
img1.src = "image1.png";
img1.alt = "alt";
document.body.appendChild(img1);
var img2 = document.createElement("img"); // ä½¿ç¨ DOM HTMLImageElement
img2.src = "image2.jpg";
img2.alt = "alt text";
document.body.appendChild(img2);
// ä½¿ç¨ææ¡£ä¸ç第ä¸ä¸ª img
alert(document.images[0].src);
è§è æµè§å¨å
¼å®¹æ§ åè§
<img>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4