0

I want that jQuery clicks on any item on the site to open the popup ad from an advertiser. Normally users would have to click on any point on the site, but I want that the Popup opens after loading.

    <script src="assets/js/popads.js" type="text/javascript"></script>
</head>
<body>
    <script>
      $(function () {
          setTimeout(function () {
              $("#clickme").click();
              ;
          }, 5000);
      });
    </script>
    <li><a id="clickme" href="#intro">Home</a></li>

I selected the Home Button for that, but it doesnt't work. The popup opens automatically if a users clicks anything on the page, thats the setting from the ad network not mine. So I don't want to wait until the user clicks, I want that jQuery clicks before the user when the page finished loading, so the popup opens. Any ideas?

Here is the full code: https://pastebin.com/0rdxahj7

Matthias
  • 5
  • 3

2 Answers2

0

You are using an id as the selector with $("#intro").click(); If you want to select the link by its href value use:

$('a[href="#intro"]');

or alternately assign an id to your link:

<a id="intro" href="#intro">Home</a>

Ron Dobley
  • 143
  • 8
  • You will need to bind a click function to the link: `$('#clickme').click(function (e) { // do whatever shows your pop-up });` – Ron Dobley Apr 11 '17 at 22:31
  • The popup opens automatically if a users clicks anything on the page, thats the setting from the ad network not mine. So I don't want to wait until the user clicks, I want that jQuery clicks before the user when the page finished loading, so the popup opens. Look at the Pastebin I added. – Matthias Apr 11 '17 at 22:40
  • Without knowing how the ad script is binding the click event it is hard to tell and you will need to figure that part out. Your document ready function will trigger a 'click' event on your home link after 5 seconds. – Ron Dobley Apr 11 '17 at 23:02
  • It doesn't click even if I change the element it doesn't click on it. I changed it to `More` Here you can watch it: https://unlogis.ch – Matthias Apr 11 '17 at 23:05
  • I do not think your ad script is binding the click event to the links. You will have to figure out what they are binding the click event to. I cannot help you there. All I can offer at this point is what I have, and that is how to trigger the click event on an element in a timeout function. – Ron Dobley Apr 12 '17 at 16:23