javascript

Callback and scope

I discovered to have some problem to fully understand callbacks scoping when trying to learn Jquery. I would add that i have little experience with the Javascript language The code: var globDom; // placeholder for DOM fragment // Getting xml file; jquery parses the file and give me back a DOM fragment // saveXML is the callback $....

Getting a JSLint warning concerning labels in Javascript

In my javascript I have this loopDeLoop: while (foo !== bar) { switch (fubar) { case reallyFubar: if (anotherFoo == anotherBar) { break loopDeLoop; } break; default: break; ...

How to disable right-click context-menu in javascript

Not that I'm trying to prevent 'View Source' or anything silly like that, but I'm making some custom context menus for certain elements. EDIT: response to answers: I've tried this: <a id="moo" href=''> </a> <script type="text/javascript"> var moo = document.getElementById('moo'); function handler(event) { event = even...

New jQuery plugin - What is the best way to get input and feedback?

I had a need for a certain functionality on my web apps and I use jQuery a lot, so I thought I would write a jQuery plugin. Since this is my first attempt to write a jQuery plugin, I would really like to get feedback from people, or maybe even get collaboration so others could work with me to modify/enhance my code. I thought the first...

Use Javascript to change which submit is activated on enter key press.

I have a form on an HTML page with multiple submit buttons that perform different actions. However, when the user is typing a value into a text input and hit enters, the browsers generally act as though the next submit button sequentially was activated. I want a particular action to occur, so one solution I found was to put in invisible ...

What is it about this Javascript code that causes it to correctly generate a table in IE?

What is it about this source code that causes it to actually generate a table in IE instead of just doing nothing. function generateATable() { tableContainer = document.getElementById("tableDiv"); var tableElement = document.createElement("table"); // Append the Table Element to the table // container. tableContaine...

How to find out user clicked 3 times through my website with javascript

Is there any way in JavaScript how to find out user clicked through the same domain 2 or more times? I need to popup a window after user clicked anywhere on the site for 3 times. I know how to do it after one click - with document.referrer or addEventListener, but then I'm lost. I need something that will capture all click events (not ...

How can I position a div over two iframes where one iframe has external (different domain) content?

I am looking for a way to position a div (it would be a pop-up that would be activated by a user hovering and/or clicking much like lightbox) over an a split iframe where the top iframe is content from my server and the bottom iframe is content from another server. Like this: ---------------------------------------- | ...

How do you read dot notation in JavaScript?

For the sake of an example, is this statement window.Number.constructor.prototype.constructor(); read like a path? C:\Users\Vista\Documents\Work\text.txt From left to right window:\Number\constructor\prototype\constructor() where window is the root object, Number is an object inside window, constructor is an object inside Number...

Is "Put Scripts at the Bottom" Correct?

In the Best Practices to improve web site Performance http://developer.yahoo.com/performance/rules.html, Steve Souders mentioned one rule "Move Scripts to the Bottom". It's a little confusing. Actually, I notice that a lot of web pages that doesn't put script at bottom, while YSlow still mark A for these pages. So, when should I follow...

JavaScript: correct prototype chain for Function

What is the correct output (meaning correct by the ECMA standard) of the following program? function nl(x) { document.write(x + "<br>"); } nl(Function.prototype); nl(Function.prototype.prototype); nl(Function.prototype.prototype == Object.prototype); nl(Function.prototype.prototype.prototype); Chrome and IE6 agree in saying: functio...

JavaScript - check if in global context

When a function is attached to an object and called: function f() { return this.x; } var o = {x: 20}; o.func = f; o.func(); //evaluates to 20 this refers to the object that the function was called as a method of. It's equivalent to doing f.call(o). When the function is called not as part of an object, this refers to the global object...

JavaScript implementation that allows access to [[Call]]

The ECMA standard defines a hidden, internal property [[Call]], which, if implemented, mean the object is callable / is a function. In Python, something similar takes place, except that you can override it yourself to create your own callable objects: >>> class B: ... def __call__(self, x,y): print x,y ... >>> inst = B() >>> inst(1...

Relation between [[Prototype]] and prototype in JavaScript

From http://www.jibbering.com/faq/faq_notes/closures.html : Note: ECMAScript defines an internal [[prototype]] property of the internal Object type. This property is not directly accessible with scripts, but it is the chain of objects referred to with the internal [[prototype]] property that is used in property accessor resolution; t...

Is JavaScript 's "new" Keyword Considered Harmful?

In another question, a user pointed out that the new keyword was dangerous to use and proposed a solution to object creation that did not use new... I didn't believe that was true, mostly because I've used Prototype, Scriptaculous and other excellent JavaScript libraries, and everyone of them used the new keyword... In spite of that, ye...

Embed javascript as base64

Hello, I'm working on a small GreaseMonkey script where I would like to embed a jQuery plugin (Markitup) so that the script is fully self contained (images + js) except for jQuery who is served from google. I found the site http://www.greywyvern.com/code/php/binary2base64 wich says that you can embed javascript with the href if you base...

Client-Side script to read and manipulate image from the web (details...)

I want to be able to use a Greasemonkey script that can take an image from a page, scan it for the darkest pixel, and then return those coordinates to the browser. Originally, I used a flash script... Greasemonkey embedded a local flash file that would fetch the image based on a URL in the source of the webpage, use ActionScript to get ...

Compressing XML in WebPage

I transfer a fair amount of XML from the server to the client, in my application (250K-500K each time). How can I compress it on the server, and decompress it on the client using standard JavaScript? Is it possible? ...

Toggle whichever element is clicked

I am using the toggle() with jQuery and I have a sidebar on my page and each header is <h2 class="sidebar-header"> One section of my code will look like: <div class="sidebar-section"> <h2 class="sidebar-header">SUBSCRIBE</h2> <p class="sidebar">Make sure you subscribe to stay in touch with the latest articles and tutorials. Cl...

Javascript RIA vs .NET GUI

I am looking at moving my company's internal business app from VB.NET to PHP. Some of the people were worried about losing GUI features that can be found in .NET. I am under the impression that with the right javascript framework, anything in .NET GUI can be replicated. While I am still researching this point, I would like to ask if for...