4

I have written a simple javascript animation code. When I right click on the document the javascript animation stops and resumes back only when the context menu closes. This happens only in IE and the animation continues if I do the same in other browsers.

I was wondering is there any work around for this so that the animation continues even when the context menu is open.

I googled and all I was able to find was:

  1. Disable right click
  2. Create a custom context menu

But could not find the reason as why this is happening only in IE.

Can anyone please explain why this is happening only in IE and also a possible solution for this (if any)?

Edit: I have checked in IE7, IE8 browsers in windows

  • You might want to specify what version(s) of IE this occurs in, and on what OS(s). – Andrew Marshall May 10 '12 at 05:05
  • Have you tried to play this animation on context menu? – Michael Sazonov May 10 '12 at 05:10
  • @Michael: I am not sure what you are asking, but the animation stops when context menu opens. my animation is something that happens on the background similar to this site [http://www.lionite.com/](http://www.lionite.com/). The parallax effect on this site stops when i right click inside or use the keyboard shortcut to pull up the context menu. – user1386170 May 10 '12 at 05:17

1 Answers1

1

There is an event called oncontextmenu. It calls the function you want when right button clicked. E.g:

​<html>
  <head></head>
  <body oncontextmenu="document.write('hello');">
  </body>
</html​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​>​​​​​​

Just try to call the function to run the animation twice - once on page start, then via oncontextmenu.

UPDATE

Check this! The script here prevents from the original right-click menu to appear during the animation. That is as far as I could get...

Michael Sazonov
  • 1,531
  • 11
  • 21
  • Thanks for the reply, I am trying to understand whether we are in same page. So I have created a sample of my code [jsfiddle](http://jsfiddle.net/VLCsj/4/). Please right click inside the result window when the circle is animating and you can see that animation pauses and resume only when context menu is closed. – user1386170 May 10 '12 at 06:47
  • Did you try to execute the function only as oncontextmenu event? – Michael Sazonov May 10 '12 at 08:36
  • Yes please see my code in the following link: [http://jsfiddle.net/VLCsj/4/](http://jsfiddle.net/VLCsj/4/) – user1386170 May 10 '12 at 09:06
  • @user1386170 Please, pay attention. The function is not executed, because jQuery library is not attached. You'd attached raphael instead. Therefore, you must call elements by the standard way. – Michael Sazonov May 10 '12 at 09:08
  • Sorry about that, i forgot to update the link please use this link - [http://jsfiddle.net/VLCsj/11/](http://jsfiddle.net/VLCsj/11/). I want the animation to continue on the background even when the context menu is open. I do not want the animation to start from the beginning. – user1386170 May 10 '12 at 09:26
  • Yeah... There are couple of logic dead ends in the script, but anyway, I guess the problem is with IE. Maybe you should try to block the menu while `interval > -1`? – Michael Sazonov May 10 '12 at 09:46
  • Thanks, but i do not want to disable the right click and was wondering whether there is a workaround for this issue. – user1386170 May 17 '12 at 10:47