본 사이트는 여러분의 사용자 경험을 개선하기 위해 유지 보수를 진행하는 동안 기능이 제한됩니다. 도움말로 문제가 해결되지 않고 질문을 하고 싶다면 Twitter의 @FirefoxSupport 및 Reddit의 /r/firefox 채널을 활용하세요.

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!