| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/API/HTMLScriptElement | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..
* Some parts of this feature may have varying levels of support.
HTML- <script> HTMLScriptElement , <script> ( HTMLElement ).
JavaScript application/javascript MIME type, , (image/*), (video/*), (audio/*), text/csv. , error; , success.
, HTMLElement.
type |
String |
MIME .
type.
|
src |
String |
URL .
src.
|
event |
String |
, HTML-. |
charset |
String |
.
charset.
|
async |
Boolean |
:
|
defer |
Boolean |
|
crossOrigin
|
String |
String,
CORS .
, ,
.
|
text |
String |
IDL |
noModule |
Boolean |
, ES2015 , JavaScript . |
referrerPolicy |
String |
String, HTML
referrerpolicy
,
, .
|
; , HTMLElement.
. , <script> <script>, ( document.currentScript). . defer async.
function loadError(oError) {
throw new URIError(
"The script " + oError.target.src + " didn't load correctly.",
);
}
function prefixScript(url, onloadFunction) {
var newScript = document.createElement("script");
newScript.onerror = loadError;
if (onloadFunction) {
newScript.onload = onloadFunction;
}
document.currentScript.parentNode.insertBefore(
newScript,
document.currentScript,
);
newScript.src = url;
}
, document.currentScript, <head>.
function loadError(oError) {
throw new URIError(
"The script " + oError.target.src + " didn't load correctly.",
);
}
function affixScriptToHead(url, onloadFunction) {
var newScript = document.createElement("script");
newScript.onerror = loadError;
if (onloadFunction) {
newScript.onload = onloadFunction;
}
document.head.appendChild(newScript);
newScript.src = url;
}
:
affixScriptToHead("myScript1.js");
affixScriptToHead("myScript2.js", function () {
alert('The script "myScript2.js" has been correctly loaded.');
});
| Specification |
|---|
| HTML # htmlscriptelement |
<script><noscript>document.currentScriptThis page was last modified on 27 . 2026 . by MDN contributors.
HTMLScriptElementBeforeUnloadEventDOMStringMapErrorEventHTMLAnchorElementHTMLAreaElementHTMLAudioElementHTMLBRElementHTMLBaseElementHTMLBodyElementHTMLButtonElementHTMLCanvasElementHTMLDListElementHTMLDataElementHTMLDataListElementHTMLDialogElementHTMLDivElementHTMLDocumentHTMLElementHTMLEmbedElementHTMLFieldSetElementHTMLFormControlsCollectionHTMLFormElementHTMLFrameSetElementHTMLGeolocationElementHTMLHRElementHTMLHeadElementHTMLHeadingElementHTMLHtmlElementHTMLIFrameElementHTMLImageElementHTMLInputElementHTMLLIElementHTMLLabelElementHTMLLegendElementHTMLLinkElementHTMLMapElementHTMLMediaElementHTMLMenuElementHTMLMetaElementHTMLMeterElementHTMLModElementHTMLOListElementHTMLObjectElementHTMLOptGroupElementHTMLOptionElementHTMLOptionsCollectionHTMLOutputElementHTMLParagraphElementHTMLPictureElementHTMLPreElementHTMLProgressElementHTMLQuoteElementHTMLSelectElementHTMLSourceElementHTMLSpanElementHTMLStyleElementHTMLTableCaptionElementHTMLTableCellElementHTMLTableColElementHTMLTableElementHTMLTableRowElementHTMLTableSectionElementHTMLTemplateElementHTMLTextAreaElementHTMLTimeElementHTMLTitleElementHTMLTrackElementHTMLUListElementHTMLUnknownElementHTMLVideoElementHashChangeEventHistoryImageDataLocationMessageChannelMessageEventMessagePortNavigatorPageRevealEventPageSwapEventPageTransitionEventPluginPluginArrayPromiseRejectionEventRadioNodeListTimeRangesUserActivationValidityStateWindowWorkletGlobalScopeYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |