Skip to content

what is the [object Window]?

Google Translate, has some bookmark let for translate with 1 click, for example: This javascript code, opens the translator page in the current page (target=_self), but I want it opens a new window (tab) for translate. so changed to: My problem is here: when I run that code, it opens a new window for translat…

using javascript’s .insertBefore to insert item as last child

I so miss jQuery. I’m working on a project where I need to get my hands dirty with good ‘ol plain Javascript again. I have this scenario: Via javascript, I want to be able to insert a new node before or after any of those children. While javascript has an insertBefore, there is no insertAfter. Ins…

How to find the 2nd closest ancestor in jQuery?

My DOM looks something like this: When the used clicks on ‘Edit’, I want to change the outer <li> to <li class=”selected>. I tried something like this, but this is not working: Any help is appreciated. Answer Go up a parent: It wasn’t working because closest starts with the…

Convert JS date time to MySQL datetime

Does anyone know how to convert JS dateTime to MySQL datetime? Also is there a way to add a specific number of minutes to JS datetime and then pass it to MySQL datetime? Answer or even shorter: Output: For more advanced use cases, including controlling the timezone, consider using http://momentjs.com/: For a …

Converting hexadecimal to float in JavaScript

I would like to convert a number in base 10 with fraction to a number in base 16. All is well there. Now I want to convert it back to decimal. But now I cannot write: As it doesn’t return the decimal part. And I cannot use parseFloat, since per MDC, the syntax of parseFloat is It wouldn’t have bee…

HTML5 Video – Percentage Loaded?

Does anyone know what event or property I need to query in order to get a percentage figure of the amount an HTML5 video has loaded? I want to draw a CSS styled “loaded” bar that’s width represents this figure. Just like You Tube or any other video player. So just like you tube a video will …