JavaScript simulate right click through code

try this instead, reason what things didn’t quite work is that the context menu is in fact bound to the oncontextmenu event. function contextMenuClick(element){ var evt = element.ownerDocument.createEvent(‘MouseEvents’); var RIGHT_CLICK_BUTTON_CODE = 2; // the same for FF and IE evt.initMouseEvent(‘contextmenu’, true, true, element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, RIGHT_CLICK_BUTTON_CODE, null); if … Read more

Loading Dojo dijit CSS from CDN

The CSS can be found on Google’s CDN. I’ve used it in a page or two. Here’s some CSS link tags. <link rel=”stylesheet” type=”text/css” href=”http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/resources/dojo.css”> <link rel=”stylesheet” type=”text/css” href=”http://ajax.googleapis.com/ajax/libs/dojo/1.4/dijit/themes/tundra/tundra.css”> Much like the libraries, you can pick a more or less specific version in the URL, so this will grab the latest in the 1.4.x chain. … Read more

Dojo require() and AMD (1.7)

The dependency array format: define([“a”, “b”, “c”], function (a, b, c) { }); can indeed be annoying and error-prone. Matching up the array entries to function parameters is a real pain. I prefer the require format (“Simplified CommonJS Wrapper”): define(function (require) { var a = require(“a”); var b = require(“b”); var c = require(“c”); }); … Read more

What is the main difference between require() and define() function in dojo and when would we use either?

require and define are part of the asynchronous module definition (AMD) API. You use define to define a module that can be consumed by other code. Generally, define will be used in a javascript file. The javascript file is defining a module. All Dojo files use define. You use require when you are not defining … Read more