[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/link [Back]  [Original]

String.prototype.link() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

String.prototype.link()

Deprecated

Avoid using this feature in new projects. HTML wrapper methods exist only for backwards compatibility. Use DOM APIs to create elements instead. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: DOM.

String link() <a> (<a href="...">str</a>) , URL .

In this article

js
link(url)

url

<a> href , & &amp; URL( ) .

<a href="url"> (url &quot; ) , str , </a> .

HTML document body .

js
const contentString = "MDN Web Docs";

document.body.innerHTML = contentString.link("https://developer.mozilla.org/");

HTML .

html
<a href="https://developer.mozilla.org/">MDN Web Docs</a>

link() HTML document.createElement() DOM API . .

js
const contentString = "MDN Web Docs";
const elem = document.createElement("a");
elem.href = "https://developer.mozilla.org/";
elem.innerText = contentString;
document.body.appendChild(elem);

Specification
ECMAScript 2027 LanguageSpecification
# sec-string.prototype.link


Web Proxy Viewer  |  New URL  |  Original Page