Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > fr.comp.lang.javascript > #3033

Re: Caractère répété

Date 2016-08-08 06:18 +0200
From Guiche <guiche@invalid>
References (1 earlier) <57a2cc05$1@news.stben.net> <no076t$67q$1@usenet.pasdenom.info> <no07ko$6jq$1@usenet.pasdenom.info> <57a3b4e0$1@news.stben.net> <no1ldt$5pd$1@usenet.pasdenom.info>
Subject Re: Caractère répété
Newsgroups fr.comp.lang.javascript
Message-ID <57a80804$1@news.stben.net> (permalink)

Show all headers | View raw


Gloops <gloops@zailes.invalid.org.invalid> Wrote in message:
>> Je vois plus ça comme une aide mais ça va
>>  ici plus loin qu'Option Explicit qui ne s'occupe que des
>>  variables non déclarées (il faut dire que JS permet des horreurs
>>  comme des noms de paramètres qui ne sont pas uniques pour une
>>  même fonction...).
> 
> Uh, ça marche, ça ?
Il paraît. Je ne connaissais pas jusqu'alors un langage qui
 autorisait ça...

Voilà la page de test dont je parlais :


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Javascript test</title>
<style>
div.c {
    padding: 5px;
    background-color: grey;
    margin-bottom: 10px;
}
p {
    background-color: lightgrey;
}
</style>
<script>
function empty() {
    var output = document.getElementById("output");
    while (output.hasChildNodes())
        output.removeChild(output.childNodes[0]);
}
function enumerate() {
    empty();
    var ol = document.createElement("ol");
    var tn = document.getElementById("tn").value;
    var from = document.getElementById("from").value;
    from = document.getElementsByTagName(from)[0];
    var elements = from.getElementsByTagName(tn);
    for (var i=0; i<elements.length; i++) {
        var li = document.createElement("li");
        li.appendChild(document.createTextNode(elements[i].tagName));
        ol.appendChild(li);
    }
    document.getElementById("output").appendChild(ol);
    return false; //onsubmit
}
</script>
</head>
<body>
    <div class="c">
        <p>bonjour</p>
        <p>vous allez bien ?</p>
    </div>
    <form onsubmit="return enumerate()">
        <label>partir de:
            <select id="from">
                <option>html</option>
                <option>body</option>
                <option>div</option>
            </select></label>
        <label>Tag Name: <input type="text" id="tn" value="*"></label>
        <button>lister</button>
    </form>
    <div id="output">
    </div>
</body>
</html>


----Android NewsGroup Reader----
http://usenet.sinaapp.com/

Back to fr.comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Caractère répété Gloops <gloops@zailes.invalid.org.invalid> - 2016-08-03 20:45 +0200
  Re:Caractère répété Guiche <guiche@invalid> - 2016-08-04 07:00 +0200
    Re: Caractère répété Gloops <gloops@zailes.invalid.org.invalid> - 2016-08-04 22:05 +0200
      Re: Caractère répété Gloops <gloops@zailes.invalid.org.invalid> - 2016-08-04 22:13 +0200
        Re: Caractère répété Guiche <guiche@invalid> - 2016-08-04 23:34 +0200
          Re: Caractère répété Gloops <gloops@zailes.invalid.org.invalid> - 2016-08-05 11:14 +0200
            Re: Caractère répété Guiche <guiche@invalid> - 2016-08-08 06:18 +0200
              Re: Caractère répété Guiche <guiche@invalid> - 2016-08-08 06:19 +0200
                Re: Caractère répété Gloops <gloops@zailes.invalid.org.invalid> - 2016-08-09 03:02 +0200
      Re: Caractère répété Guiche <guiche@invalid> - 2016-08-04 23:48 +0200

csiph-web