Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

problem with manual click versus javascript: simulated click

  • 2 trả lời
  • 1 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi 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!

Tất cả các câu trả lời (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!