aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/selection/tostring/index.md
blob: 23ce05469689aa93133c629b4f6dd168824af267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
title: toString
slug: Web/API/Selection/toString
tags:
  - Référence_du_DOM_Gecko
translation_of: Web/API/Selection/toString
---
{{ ApiRef() }}

### Résumé

Renvoie une chaîne de caractères représentant l'actuel objet `selection`, i.e. le texte sélectionné.

### Syntaxe

    string =sel.toString()

- `string` est la représentation sous la forme d'une chaîne de caractères de la sélection.

### Paramètres

Aucun.

### Description

Cette méthode renvoie le texte sélectionné.

En [JavaScript](fr/JavaScript), cette méthode est appelée automatiquement pour des objets `selection` aux fonctions nécessitant un paramètre `string` :

    alert(window.getSelection()) // Appel automatique
    alert(window.getSelection().toString())  // Appel explicite

### Voir aussi

- [Object.toString](fr/R%c3%a9f%c3%a9rence_de_JavaScript_1.5_Core/Objets_globaux/Object/toString)