I am building a Html 5 website using push state and I wondering whether its possible in javascript or JQuery to detect whether the browser’s back button has been pushed. I would like to include it in an if statement like so: Answer You’re looking for the popstate event. An example: Or with the eve…
Tag: javascript
“Cannot read property ‘content’ of null”: Psuedo Elements
I adapted some code from here in order to detect orientation changes in my Phonegap app (to load different CSS files for landscape and portrait). I’m getting a “cannot read property ‘content’ of null error, implying there’s something wrong with the DOM call. The code involves add…
Safari Developer Tools: How to Preserve Console Log Upon Navigation?
When using Safari Web Inspector to read the JavaScript console output, the log is reset upon navigation i.e. going from page index.html to mail.html clears the console output. In the Chrome Developer Tools, I can easily preserve the log by right clicking on the console space and selecting Preserve Log Upon Na…
How to programmatically trigger a D3 drag event?
So i have some data binded with drag event listeners : Now I want to call this onDrag function on a certain node programmatically. I do know the same is possible with standard events by doing Is there any way to do so ? Thanks. Answer Save the callback (the one you pass into the drag handler) in a variable
Styling a voting system
I have made a sample voting system here: Sample Voting System However after repeated attempts I couldn’t get it to style the way I want because the developer has used way too many divs here. Either the font becomes too big or gets overlapped with the number or goes out of proportion, etc. I want it to l…
How to convert JSON object to JavaScript array?
I need to convert JSON object string to a JavaScript array. This my JSON object: And I want to have: How can I achieve this? Answer http://jsfiddle.net/MV5rj/
Add a space on top of a #page HTML link
When I have a link that loads a section within the same page, the link will make the section clicked on load at the top of the browser window, I need to somehow add a space/gap of like 100px on top of all these sections that are linked like this. Any ideas on how to do this? Answer In your
Dashboard using google charts with two tables
I’m trying to create a Dashboard with column chart and a few category filters in my app, I have data like this : but I have to visualize not this data, but a table with total amount of people with same number of children: [‘1 child’, ‘2 children’, ‘3 children’], [1, 2…
jQuery AddClass then removing a class
In my Rails application, I send an Ajax request when the user hits the Save button, when it sends the request, I can return some jQuery. What I’d like to do is add a class (saving), have a delay and then remove the class. So, I added this: For some reason, it isn’t working. What am I doing wrong? …
Simple bookmarklet not working in chrome
I am new to bookmarklet coding and i have run into a problem where the regular javascript works fine in the browser but not the bookmarklet version. I had found a bookmarklet which finds a image and turns it into BB code and that works fine, however it loads jQuery and i did not want it doing that all the