-2

i have very basic html structure which looks neat from all angle. i just want to fire one timeout after 30 seconds but its not working. when i click manually on link they work just fine.

here is jsfiddle link https://jsfiddle.net/r49bu1sp/

when i click on chrome extension it works just fine and popup opens but i want this popup to show after 30 seconds and code is very simple and looks correct. any help will be great

<!DOCTYPE html>
<html lang="en" >
<head>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
 <link rel="stylesheet" href="//sandboxwordpress.com/js/popup.css">
</head>

<body>
  <nav class="primary_nav_wrap">
    <ul>
      <li><a href="#"><img src="cp/menuicon.png" width="25"></a> 
      <li><a href="#popup_chrome" id="popup_chrome1">Chrome Extension</a></li>    
    </ul>
  </li>      
</ul>
</nav>

<script>jQuery(document).ready(function($) {
  setTimeout(function() {
   $("#popup_chrome1").trigger('click');}, 30000);

   });
</script>

<div id="popup_chrome" class="overlay">
    <div class="popup">
        <h2>Download Chrome Extension</h2><br>
        <a class="close" href="#">×</a>
        <div class="content">
<br /><a href="https://chrome.google.com/webstore/detail/sandbox-for-wordpress/ffifhcgbcpgbiblodgfoeboejkepjaji" target="_blank" class="myButton_sub">Download</a>
            </div>
        </div>
    </div> 

</body>

</html>
Steeve
  • 423
  • 2
  • 9
  • 23
  • 1
    Though not a cause of error, I suggest moving your ` – Tyler Roper Jun 26 '19 at 18:44
  • Note, automatically clicked buttons that lead to installing your extension may violate the google web store policies related to deceptive install practices and can result in having your extension banned from the web store. – Wesley Smith Jun 27 '19 at 02:29
  • 1
    @DelightedD0D thanks for pointing out. we are not going to do any such thing. when users is in website popup will open after 30 seconds and they will be shown benefits of this extension. if they click then they will be taken to google chrome store and there they have to click on install then only it will be installed. so no deceptive behaviour. thanks for pointing out – Steeve Jun 27 '19 at 04:08

1 Answers1

2

It seems you are using the wrong id in your js.

You would want to use #popup_chrome1. That is the id for the hyperlink you want to click.

You should also specify the element before you click. Try this below.

$("#popup_chrome1")[0].click();
patrickSmith
  • 244
  • 1
  • 3
  • 12
  • that link is dummy. i want it to fire automatically after 30 seconds and open popup – Steeve Jun 26 '19 at 18:45
  • Why this [0] is working and without it it's not working. Can u plz explain little – Steeve Jun 26 '19 at 19:46
  • Check out this answer from a similar question. He does a better job explaining it than I would. https://stackoverflow.com/a/21334234/1270521 – patrickSmith Jun 26 '19 at 20:28