| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/String/anchor | [Back] [Original] |
Get to know MDN better
Cette page a t traduite partir de l'anglais par la communaut. Vous pouvez contribuer en rejoignant la communaut francophone sur MDN Web Docs.
vitez d'utiliser cette fonctionnalit dans de nouveaux projets. HTML wrapper methods exist only for backwards compatibility. Use DOM APIs to create elements instead. Cette fonctionnalit peut tre candidate la suppression des standards web ou des navigateurs.
Envisagez d'utiliser plutt les fonctionnalits suivantes : DOM.
La mthode anchor() permet de crer une ancre HTML <a> qui est utilis comme cible hypertexte.
str.anchor(name);
nameUne chane de caractres reprsentant l'attribut name de la balise crr.
Une chane de caractres qui reprsente un lment HTML <a>.
On utilise la mthode anchor() pour crer et afficher des ancres dans un document HTML l'aide de JavaScript.
Ici la chane reprsente le texte que verra l'utilisateur. Le paramtre name reprsente l'attribut name de l'lment <a>.
Les ancres cres avec la mthode anchor deviennent des lments accessibles travers le tableau document.anchors.
var maChane = "Table des matires";
document.body.innerHTML = maChane.anchor("ancre_contenu");
produira le code HTML suivant :
<a name="ancre_contenu">Table des matires</a>
if (!String.prototype.anchor) {
String.prototype.anchor = function (x) {
return '<a name="' + x + '">' + this + "</a>";
};
}
| Spcification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-string.prototype.anchor |
Cette page a t modifie le 3 aot 2023 par les contributeurices du MDN.
StringString.prototype.anchor()String.prototype.at()String.prototype.big()String.prototype.blink()String.prototype.bold()String.prototype.charAt()String.prototype.charCodeAt()String.prototype.codePointAt()String.prototype.concat()String.prototype.endsWith()String.prototype.fixed()String.prototype.fontcolor()String.prototype.fontsize()String.prototype.includes()String.prototype.indexOf()isWellFormed()String.prototype.italics()String.prototype.lastIndexOf()String.prototype.link()String.prototype.localeCompare()String.prototype.match()String.prototype.matchAll()String.prototype.normalize()String.prototype.padEnd()String.prototype.padStart()String.prototype.repeat()String.prototype.replace()String.prototype.replaceAll()String.prototype.search()String.prototype.slice()String.prototype.small()String.prototype.split()String.prototype.startsWith()String.prototype.strike()String.prototype.sub()String.prototype.substr()String.prototype.substring()String.prototype.sup()String.prototype.toLocaleLowerCase()String.prototype.toLocaleUpperCase()String.prototype.toLowerCase()String.prototype.toString()String.prototype.toUpperCase()toWellFormed()String.prototype.trim()String.prototype.trimEnd()String.prototype.trimStart()String.prototype.valueOf()String.prototype[@@iterator]()Object/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Certaines parties de ce contenu sont protges par le droit d'auteur 19982026 des contributeurs individuels de mozilla.org. Contenu disponible sous une licence Creative Commons.
| Web Proxy Viewer | New URL | Original Page |