ok I’ve got a dropdown menu, and I use It has a couple of options, the problem though, when I select the first option – nothing happens – because it is already selected. Is there any way to make it happen? So far I was using an additional empty option, which was selected by default and did n…
Tag: javascript
Pass a string parameter in an onclick function
I would like to pass a parameter (i.e. a string) to an Onclick function. For the moment, I do this: with result.name for example equal to string “Add”. When I click on this button, I have an error that says that “Add is not defined”. Since this function call works perfectly with a nume…
detecting a redirect with javascript – how?
Is there any way to detect whether a webpage is going to redirect me to another, knowing its URL? I mean the situation when you type URL in a text field and the script examines it for 3xx redirections. Answer Yes, you can do this quite easily in Javascript. It’d look something like: Unfortunately, this …
Falling hearts animation for browsers
Recently I have downloaded falling hearts animation from this . I have pasted the code below too. It simply displays a heart in my page.and falling hearts animation is not working.I am not able to identify the problem. will anyone tell me what changes I have to made in order to get the hearts falling animatio…
Sort an array by a preferred order
I’d like to come up with a good way to have a “suggested” order for how to sort an array in javascript. So say my first array looks something like this: Now all I care about, is that the sorted results starts out in this order: After that, I Want the remaining values to be presented in their…
Google Analytics: How to track pages in a single page application?
Currently in my website, I used HTML5’s pushState() and popState in links to increase the speed. However, this doesn’t really change the real URL and it looks like it will affect and mess up the Google Analytics’s code. (doesn’t show a url change) Is there a possible solution for this?…
jquery – How to determine if a div changes its height or any css attribute?
How can I trigger an event when a div changes its height or any css attribute? I have a div with id = mainContent. I want jquery to automatically trigger an event when it changes its height. I did something like this: I know its wrong. Here’s my whole code (I pasted all of it because I can’t get i…
window.onbeforeunload in Chrome: what is the most recent fix?
Obviously, window.onbeforeunload has encountered its fair share of problems with Chrome as I’ve seen from all the problems I’ve encountered. What’s the most recent work around? The only thing I’ve got even close to working is this: However, if I substitute return “alert” wi…
DOM/jQuery events propagation differences between input types
As we know, returning false from a DOM event handler will stop the propagation of the event. But I recently discovered that the behavior of different elements varies with respect to this event. For example, consider the following: The surrounding container has a click handler that returns false: Within the di…
Best way to create large static DOM elements in JavaScript?
I have many elements that one of my JS widgets needs to create and add to the DOM often. They never change. So one option would be to store the HTML itself as a string in JS and use JQuery to create the elements from the string, then append it to the document: Another option is to write a function