Onclick javascript

Salut les ga, j'ai un petit souci avec un code java window.blur() si quelqu'un pourai m'aide.
la fenetre ne veux pas s'ouvrir en arriere plan..


<script>
function below()
{
Url = new Array;
Url[0] = "https://www.commentcamarche.net/";
Url[1] = "https://www.facebook.com/";

ChoixLien = Math.floor(Math.random() * Url.length)

win=window.open(Url[ChoixLien],"mywindow",'toolbar=0,scrollbars=0,width=1366,height=768');
setTimeout("win.close()",2000);
window.blur();

}
</script>
<body>
<input type="button" VALUE="Click!" onClick="below()">
</body>
</html>

3 réponses

  1. salut je ne suis pas sur que cela repond a ta question car je n'ai pas tro compris ton probleme mais essay ce morceaux de code
    <script>
    function below()
    {
    Url = new Array;
    Url[0] = "https://www.commentcamarche.net/";
    Url[1] = "https://www.facebook.com/";
    ChoixLien = Math.floor(Math.random() * Url.length)
    win=window.open(Url[ChoixLien],"mywindow",'toolbar=0,scrollbars=0,width=1366,height=768');
    //setTimeout("win.close()",2000);
    win.blur();
    }
    </script>
    <body>
    <input type="button" VALUE="Click!" onClick="below()">
    </body>
    </html>
    
    1. ok essaies ca
      <html>
      <script type="text/javascript">
      function openUnder(url, width, height) {
          var openUnderWindow, nav = navigator.userAgent,
              isGecko = /rv:[2-9]/.exec(nav),
              hackString;
      
          hackString = nav.indexOf('Chrome') > -1 ? "scrollbar=yes" : "toolbar=0,statusbar=1,resizable=1,scrollbars=0,menubar=0,location=1,directories=0";
      
          openUnderWindow = window.open("about:blank", "title", hackString + ",height=" + height + ",width=" + width);
      
          if (isGecko) {
              openUnderWindow.window.open("about:blank").close();
          }
      
          openUnderWindow.document.location.href = url;
      
      
          setTimeout(window.focus);
          window.focus();
          openUnderWindow.blur();
      }
      function below()
      {
      	Url = new Array;
      	Url[0] = "https://www.commentcamarche.net/";
      	Url[1] = "https://www.facebook.com/";
      	ChoixLien = Math.floor(Math.random() * Url.length)
      	openUnder(Url[ChoixLien], 800, 768);
      	return false;
      	}
      </script>
      <body>
      <input type="button" VALUE="Click!" onClick="below()">
      </body>
      </html>
      
      1. On i et presque, ok pour firefox et explore mais la fenetre ne se referme pas automatiquement..
        pour chrome rien a changer..je te remerci
      2. oui jai enleve setTimeout("win.close()",2000); tu doi le mettre apres openUnderWindow.blur(); dans la fonction openUnder
      3. J'ai reussi a faire un petit quelque chose mais le code me parai bizarr...au niveaux du win.open.

        <script>
        function below()
        {
        Url = new Array;
        Url[0] = "https://www.commentcamarche.net/";
        Url[1] = "https://www.facebook.com/";

        ChoixLien = Math.floor(Math.random() * Url.length)

        win=window.open(Url[ChoixLien],"mywindow",'toolbar=0,scrollbars=0,width=1366,height=768');

        win.open("win.blur");
        setTimeout("win.close()",2000);
        }
        </script>
        <body>
        <input type="button" VALUE="Click!" onClick="below()">
        </body>
        </html>
    2. Salut, msarah merci pour ton aide, j'ai un petit souci avec le code window.blur() je voudrai faire apparaitre le lien en arriere plan. C'est a dire que la page s'ouvre entre la page sur la quelle je suis et mon fond d'ecran si tu vois se que je veux dire...je fais mais essai sur https://www.w3schools.com/js/ mais sans sucsses..