Good day!

I am doing banner advertising, but does not pass moderation Yandeks.Displeya, since the transition to the target web page with a banner carried by all the mouse buttons when you need only left.

Adobe animate offers the following code snippet for a button leading to a web page (when you click any mouse button):

/* НаТмитС для ΠΏΠ΅Ρ€Π΅Ρ…ΠΎΠ΄Π° ΠΊ Π²Π΅Π±-страницС ΠŸΡ€ΠΈ Π½Π°ΠΆΠ°Ρ‚ΠΈΠΈ Π½Π° ΡƒΠΊΠ°Π·Π°Π½Π½Ρ‹ΠΉ экзСмпляр символа производится Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ° Π²Π΅Π±-страницы Π² Π½ΠΎΠ²ΠΎΠΌ ΠΎΠΊΠ½Π΅ обозрСватСля. Π˜Π½ΡΡ‚Ρ€ΡƒΠΊΡ†ΠΈΠΈ: 1. Π—Π°ΠΌΠ΅Π½ΠΈΡ‚Π΅ http://www.adobe.com Π½Π° адрСс ΠΆΠ΅Π»Π°Π΅ΠΌΠΎΠΉ Π²Π΅Π±-страницы. НС удаляйтС ΠΊΠ°Π²Ρ‹Ρ‡ΠΊΠΈ (""). */ this.button_2.addEventListener("click", fl_ClickToGoToWebPage); function fl_ClickToGoToWebPage() { window.open("http://google.ru", "_blank"); } 

Tell me, please, how to change it so that the transition is carried out only with the left button of the mouse.

PS replacing click on onΠ‘lick does not work. As a result, the transition never done.

    2 answers 2

    Canvas event is triggered when you click on any button, but you can get a standard event MouseEvent object and determine which mouse button was pressed. If you need only the left, then its code is zero.

     this.button_2.addEventListener("click", fl_ClickToGoToWebPage); function fl_ClickToGoToWebPage(event) { if(event.nativeEvent.button == 0) { window.open("http://google.ru", "_blank"); } } "); this.button_2.addEventListener("click", fl_ClickToGoToWebPage); function fl_ClickToGoToWebPage(event) { if(event.nativeEvent.button == 0) { window.open("http://google.ru", "_blank"); } } 
    • Thanks a lot for the answer, it works. - Maria Zakharova

    Found another solution to the problem. The HTML-document, insert the following code:

     <script> function getUrlParam(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } </script> <style>*{margin:0;padding:0;}</style> <title>HTML5_Ad_Demo</title> </head> <body> <a id="click1_area" href="#" target="_blank" style="width: 240px; height: 400px; cursor: pointer; position: absolute; z-index: 9;"></a> <script> document.getElementById("click1_area").href = getUrlParam('link1'); </script> ] /, "\\ [") replace (/ [\]] /, "\\.]"); <script> function getUrlParam(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } </script> <style>*{margin:0;padding:0;}</style> <title>HTML5_Ad_Demo</title> </head> <body> <a id="click1_area" href="#" target="_blank" style="width: 240px; height: 400px; cursor: pointer; position: absolute; z-index: 9;"></a> <script> document.getElementById("click1_area").href = getUrlParam('link1'); </script> , "")); <script> function getUrlParam(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } </script> <style>*{margin:0;padding:0;}</style> <title>HTML5_Ad_Demo</title> </head> <body> <a id="click1_area" href="#" target="_blank" style="width: 240px; height: 400px; cursor: pointer; position: absolute; z-index: 9;"></a> <script> document.getElementById("click1_area").href = getUrlParam('link1'); </script> cursor: pointer; position: absolute; z-index: 9;"> </a> <script> function getUrlParam(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } </script> <style>*{margin:0;padding:0;}</style> <title>HTML5_Ad_Demo</title> </head> <body> <a id="click1_area" href="#" target="_blank" style="width: 240px; height: 400px; cursor: pointer; position: absolute; z-index: 9;"></a> <script> document.getElementById("click1_area").href = getUrlParam('link1'); </script> getUrlParam ( 'link1').; <script> function getUrlParam(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } </script> <style>*{margin:0;padding:0;}</style> <title>HTML5_Ad_Demo</title> </head> <body> <a id="click1_area" href="#" target="_blank" style="width: 240px; height: 400px; cursor: pointer; position: absolute; z-index: 9;"></a> <script> document.getElementById("click1_area").href = getUrlParam('link1'); </script>