Vous êtes sur la page 1sur 3

Correction Tp 3 :

<!-- HTML Exercice 3.1 -->


        <!-- <form name="f1">
            <div class="titre">Blur and Focus</div>
            <button onclick="ouvrir()">Open Google</button>
            <button onclick="accés()">Focus Google</button>
            <button onclick="fermer()">Close Google</button>
        </form> -->
<script>
        // Script Exercice 3.1
        // f désigne la page google
        // f no9sed biha fenetre
        // var f;
        // function ouvrir(){
        //      f=window.open("htpps://www.google.tn","fen","width=400,height=400");
        // }
        // ouvrir();
        // function accés(){
        //     f.focus();
        // }
        // accés();
        // function fermer(){
        //     f.close();
        //     window.open("pup.html");
        // }

    </script>
<!-- HTML Exercice 3.2 -->
        <!-- <a href="http://www.google.com">lien1</a><br>
        <a href="http://www.facebook.com">lien2</a><br>
        <a href="http://www.yahoo.com">lien3</a><br> -->
        <script>
            // Exercice 3.2
            // 1
        /*document.write(window.document.title+"<br>");
        // 2
        document.bgColor="#E0E0E0" ;
        // 3
        document.write(window.document.bgColor+"<br>");
        // 4
        document.write(document.links[0].protocol+"<br>");
        // 5
        window.document.links[0].protocol="https";
        // 6
        document.write(document.links[0].href+"<br>");
        document.write(document.links[1].href+"<br>");
        document.write(document.links[2].href+"<br>");
        // 7
        document.links[0].href="lien1.html" ;
        document.links[1].href="lien2.html" ;
        document.links[2].href="lien3.html" ;
        // 8
        document.write(document.links[0].href+"<br>");
        document.write(document.links[1].href+"<br>");
        document.write(document.links[2].href+"<br>");   */
// Ecercice 3.3
<!-- HTML Exercice 3.3 -->
         <!-- <img id="im1" name="img1" onclick="ouvr1()"
src="333240747_1126542974679764_5734557965089681853_n.jpg" alt="image1">
         <img id="im2" name="img2" onclick="ouvr1()" src="images.jpg" alt="image2"> -->
        // 1
        // function ouvr1(){
        //     let x=document.images[0].src;
        //     document.images[0].src=document.images[1].src;
        //     document.images[1].src=x;
        // }
        // ouvr1();
        // 2
        // function ouvr1(){
        //     let x=document.img1.src;
        //     document.img1.src= document.img2.src;
        //     document.img2.src=x;
        // }
        // ouvr1();
        // 3
        // function ouvr1(){
        //     let x= document.getElementsByTagName("img")[0].src;
        //     document.getElementsByTagName("img")[0].src= document.getElementsByTagName("img")[1].src;
        //     document.getElementsByTagName("img")[1].src=x;
        // }
        // ouvr1();
        // 4
        // function ouvr1(){
        //     let x= document.getElementById("im1").src;
        //     document.getElementById("im1").src= document.getElementById("im2").src;
        //     document.getElementById("im2").src=x;
        // }
        // ouvr1();
// Exercice 3.4
        // Méthode par la méthode prédefinie forms
        // function calc(){
        //     document.forms[0].elements[2].value=eval(document.forms[0].elements[0].value);
        // }
        // calc();

        // Méthode avec name


        // function calc(){
        //     document.form1.text2.value=eval(document.form1.text.value);
        // }
        // calc();

        // Méthode avec getElementsByTagName


        // function calc(){
        //     document.getElementsByTagName("input")
[2].value=eval(document.getElementsByTagName("input")[0].value);
        // }
        // calc();

        // Méthode avec getElementById


        // function calc(){
        //     document.getElementById("in2").value=eval(document.getElementById("in1").value);
        //     alert(document.getElementsByTagName("input")[1].value);
        // }
        // calc();
<!-- HTML Exercice 3.4 -->
         <!-- <form name="form1">
            Expression mathématique :
            <input id="in1" type="text" name="text">
            <input type="button" onclick="calc()" id="btn1" value="Evaluation"></button>
            <input id="in2" type="text" name="text2">
         </form> -->
<!-- HTML Exercice 3.5 -->
         <!-- <div id="d1">La date est: -->
            <script>
            // Question 1 Exercice 3.5
            // let dateToday = new Date();
            // document.write(dateToday.toLocaleString());
            // document.getElementById("d1").innerHTML = `La date est ${dateToday.getDate()}/$
{dateToday.getMonth()}/${dateToday.getFullYear()}, ${dateToday.getHours()}:${dateToday.getMinutes()}:$
{dateToday.getSeconds()}`
           

            // document.write(`Today is ${new Date().getDay()}${new Date().getMonth()}${new


Date().getFullYear()} ${new Date().getHours()}:${new Date().getMinutes()}:${new
Date().getSeconds()}`)</script>
            </script>
            </div>

            <!-- Reste de l'Exercice 3.5 -->


            <!-- <div id="d2">Détail de la date</div>
            <div id="d3"> -->
            <script>
            //     if(dateToday.getDay()===0){
            //     document.write("Le jour est : Dimanche<br>");
            // }
            // else if(dateToday.getDay()===1){
            //     document.write("Le jour est : Lundi<br>");
            // }
            // else if(dateToday.getDay()===2){
            //     document.write("Le jour est : Mardi<br>");
            // }
            // else if(dateToday.getDay()===3){
            //     document.write("Le jour est : Mercredi<br>");
            // }
            // else if(dateToday.getDay()===4){
            //     document.write("Le jour est : Jeudi<br>");
            // }
            // else if(dateToday.getDay()===5){
            //     document.write("Le jour est : Vendredi<br>");
            // }
            // else if(dateToday.getDay()===6){
            //     document.write("Le jour est : Samedi<br>");
            // }
            // else{
            //     document.write("Le jour est inexistant<br>");
            // }

            // document.write("Le Date de jour est: " + dateToday.getDate() + "<br/>");


            // document.write("Le mois est: " + (dateToday.getMonth()+1) + "<br/>");
            // document.write("L'année est: " + dateToday.getFullYear() + "<br/>");
            // document.write("L'heure est:" + dateToday.getHours() + "<br/>");
            // document.write("Les Minutes est: " + dateToday.getMinutes() + "<br/>");
            // document.write("Les Secondes est: " + dateToday.getSeconds() + "<br/>");
            // document.write("Le Date en format GMT est: " + dateToday.toGMTString() + "<br/>");
            // document.write("Le Date en format LOCAL est: " + dateToday.toLocaleString() + "<br/>");
            // document.write("Le Date en format UNIVERSEL est: " + dateToday.toUTCString() + "<br/>")

Vous aimerez peut-être aussi