Open a URL in a new tab (and not a new window)

Nothing an author can do can choose to open in a new tab instead of a new window; it is a user preference. (Note that the default user preference in most browsers is for new tabs, so a trivial test on a browser where that preference hasn’t been changed will not demonstrate this.) CSS3 proposed target-new, but the … Read more

Remove element by id

The DOM is organized in a tree of nodes, where each node has a value, along with a list of references to its child nodes. So element.parentNode.removeChild(element) mimics exactly what is happening internally: First you go the parent node, then remove the reference to the child node. As of DOM4, a helper function is provided to do … Read more

What is lexical scope?

I understand them through examples. 🙂 First, lexical scope (also called static scope), in C-like syntax: Every inner level can access its outer levels. There is another way, called dynamic scope used by the first implementation of Lisp, again in a C-like syntax: Here fun can either access x in dummy1 or dummy2, or any x in any function that call fun with x declared in it. will print 5, will print 10. The … Read more

Tricky : ‘dict’ object is not callable

What you’ve run into is called “shadowing”. You’ve created an object in some namespace (either the global namespace of your module, or the local namespace of a function) that has the same name as a the builtin dict type. This prevents you from accessing the builtin dict in the usual way. You can still get to it, with a bit more … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)