Bonjour,
J'affiche du code dans une page HTML et je souhaite pouvoir mettre un lien pour le sélectionner.
Voic mes soucis :
- Comment faire pour ne pas sélectionner les numéros de lignes ?
- Quand je sélectionne des lignes et les affiches avec alert, je n'ai pas les retour chariot.
Voici mon code
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
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
36
37
38
39
40
41
42
43
44 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <title>test</title> </head> <body> <script type="text/javascript" language="JavaScript"> function selectionner(objet) { if ( window.getSelection ) { alert(window.getSelection()); } else if (document.getSelection) { alert(document.getSelection()); } else if (document.selection) { alert(document.selection.createRange().text); } return true; } </script> <a href="#" onclick="selectionner(this);">sélectionnez</a> <pre> <code id="contenuCoded0e132" class="contenuCode"><span class="numerotation_code">1.</span><code class="python_comment1">#</code><code class="python_comment1"> </code><code class="python_comment1">-*-</code><code class="python_comment1"> </code><code class="python_comment1">coding=utf-8</code><code class="python_comment1"> </code><code class="python_comment1">-*-</code><code class="python_comment1"> </code> <span class="numerotation_code">2.</span><code class="python_comment1">#</code><code class="python_comment1"> </code><code class="python_comment1">changements</code><code class="python_comment1"> </code><code class="python_comment1">de</code><code class="python_comment1"> </code><code class="python_comment1">type</code><code class="python_comment1"> </code> <span class="numerotation_code">3.</span><code class="python_comment1">#</code><code class="python_comment1"> </code><code class="python_comment1">int</code><code class="python_comment1"> </code><code class="python_comment1">--></code><code class="python_comment1"> </code><code class="python_comment1">str,</code><code class="python_comment1"> </code><code class="python_comment1">float,</code><code class="python_comment1"> </code><code class="python_comment1">bool</code><code class="python_comment1"> </code> <span class="numerotation_code">4.</span>x<code class="python_operator">=</code><code class="python_digit">4</code> <span class="numerotation_code">5.</span><code class="python_keyword1">print</code> x, <code class="python_keyword2">type</code>(x) <span class="numerotation_code">6.</span>x<code class="python_operator">=</code><code class="python_keyword2">str</code>(<code class="python_digit">4</code>) <span class="numerotation_code">7.</span><code class="python_keyword1">print</code> x, <code class="python_keyword2">type</code>(x) nbjh hf jjdj hf jf jfv jfv jdfv jfjdhfv jfvj fdjfhv jf vfd jfvdf f jdfdjf jzdfhdf jdfvjdfvdjfv jdfv jzdfv jzfv jfv <span class="numerotation_code">8.</span>x<code class="python_operator">=</code><code class="python_keyword2">float</code>(<code class="python_digit">4</code>) <span class="numerotation_code">9.</span><code class="python_keyword1">print</code> x, <code class="python_keyword2">type</code>(x) <span class="numerotation_code">10.</span>x<code class="python_operator">=</code><code class="python_keyword2">bool</code>(<code class="python_digit">4</code>) <span class="numerotation_code">22211.</span><code class="python_keyword1">print</code> x, <code class="python_keyword2">type</code>(x) </code> </pre> </body> </html>
pour vos aides !
Partager