We're calling on all EU-based Mozillians with iOS or iPadOS devices to help us monitor Apple’s new browser choice screens. Join the effort to hold Big Tech to account!

Шукати в статтях підтримки

Остерігайтеся нападів зловмисників. Mozilla ніколи не просить вас зателефонувати, надіслати номер телефону у повідомленні або поділитися з кимось особистими даними. Будь ласка, повідомте про підозрілі дії за допомогою меню “Повідомити про зловживання”

Докладніше

Ця тема перенесена в архів. Якщо вам потрібна допомога, запитайте.

problem with manual click versus javascript: simulated click

  • 2 відповіді
  • 1 має цю проблему
  • 1 перегляд
  • Остання відповідь від toes314

more options

Hi!

I have been trying to simulate from javascript, a click on a link. Sounds simple, yes?

I have FF configured to open new pages in new tabs, by default. So I'd like the simulated click to open the page pointed to by the link, in a new tab. The way I'm simulating the click does attempt to open the page, but the built-in pop-up blocker treats that as a pop-up. That was a surprise to me!

I've created a couple trivial HTML pages to illustrate the problem.

Although I normally have quite a few "extensions" loaded into FF, I am using a separate very simple FF profile to try to make sure the extensions aren't causing the problem.

The first HTML page I'm using to test is literally this:

<meta charset="US-ASCII"> Click Me! <script type="text/javascript"> document.anchors[0].click() ; </script>


The page in the href is literally just this:

<meta charset="US-ASCII"> GOT IT!

I've also tried an alternative approach with initMouseEvent() and dispatchEvent() with an event sequence like, mouseover, mousedown, mouseup, click, but then nothing at all happens.

I would hope there should be a way to do this in FF that doesn't cause FF to treat the result as a pop-up, even then trying to open a page in another tab. But even if I wanted to configure the pop-up, it doesn't appear possible. I'm doing very simple testing with local pages, using the file: scheme. The file: scheme doesn't appear to be supported by the pop-up blocker.

Any explanation of how to do this in FF would be greatly appreciated!

Hi! I have been trying to simulate from javascript, a click on a link. Sounds simple, yes? I have FF configured to open new pages in new tabs, by default. So I'd like the simulated click to open the page pointed to by the link, in a new tab. The way I'm simulating the click does attempt to open the page, but the built-in pop-up blocker treats that as a pop-up. That was a surprise to me! I've created a couple trivial HTML pages to illustrate the problem. Although I normally have quite a few "extensions" loaded into FF, I am using a separate very simple FF profile to try to make sure the extensions aren't causing the problem. The first HTML page I'm using to test is literally this: <!DOCTYPE html> <html> <head> <meta charset="US-ASCII"> </head> <body> <a id="click_anchor" name="click_anchor" href="file:///home/toes/src/js/got_it.html" target="_blank"> Click Me! </a> <script type="text/javascript"> document.anchors[0].click() ; </script> </body> </html> The page in the href is literally just this: <!DOCTYPE html> <html> <head> <meta charset="US-ASCII"> </head> <body> GOT IT! </body> </html> I've also tried an alternative approach with initMouseEvent() and dispatchEvent() with an event sequence like, mouseover, mousedown, mouseup, click, but then nothing at all happens. I would hope there should be a way to do this in FF that doesn't cause FF to treat the result as a pop-up, even then trying to open a page in another tab. But even if I wanted to configure the pop-up, it doesn't appear possible. I'm doing very simple testing with local pages, using the file: scheme. The file: scheme doesn't appear to be supported by the pop-up blocker. Any explanation of how to do this in FF would be greatly appreciated!

Усі відповіді (2)

more options

See this pref for the behavior with JavaScript window.open() calls.

A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.

The helpers at that forum are more knowledgeable about web development issues.
You need to register at the MozillaZine forum site in order to post at that forum.

more options

Thanks for the info!