javascript

hide part of form

Hi, I have an asp.net mvc application where I want to hide/display part of form based on selected line in a dropdown list. This is done by jQuery script: <script type="text/javascript" > $(document).ready(function() { $('#owners').change(function() { $("select option:selected").each(function() { $...

Does === exist in jquery

I'm aware of the === operator in PHP which connotes not only value equality, but type matching also i.e. if (20 === "20") //false Is there something similar in javascript if I'm using jquery? Examples code could help too. Thanks ...

get client machine timezone in asp.net mvc

How to get the time zone id (ex.: Central Standard Time) of the client machine in asp.net mvc? ...

How do I access currently selected text from a bookmarklet, while on gmail.com

I'm using FF 3.5.3 on Windows Vista. This is my (edited for shortness) bookmarklet: javascript:(function(){ var text = window.content.getSelection().toString(); alert(text); })(); Works, but not on gmail.com. Probably due to dynamicly generated content. I'm aware of this workaround, but it only works for Firefox extensions. ...

Javascript function to convert color names to hex codes

Hi, Is there a built-in function that would convert a color by name into its hex representation? Like I want to pass 'white' and receive '#FFFFFF'. I really want to avoid coding all hundred if's myself :) Thank you! Andrey ...

How do Javascript's "multiple execution contexts" work?

Javascript does not have visible threads (yet -- Worker Threads are coming, see more info in http://stackoverflow.com/questions/30036/javascript-and-threads). However, it does seem to have multiple execution contexts that appear to exist simultaneously -- independent, when you have multiple Firefox Windows, and multiple Firefox/IE tabs....

Working with multiple jquery-ui-dialogs

Hi, I have a table with a lot of text inputs like these: (they are marks of tests for a few students). Every field has an associated icon for adding a comment, so when the icon is clicked, a dialog must be shown with a textarea, and then save its value to a hidden input. An example of a mark field: <input class="num" type="text" si...

How to avoid spaghetti code in Javascript

I'm finding myself writing a lot of spaghetti in Javascript when I have to deal with asynchronous applications (specially when dealing with OpenSocial code where all the data has to be obtained through JS). The usual pattern is something like: User logs into the application for the first time, get his data. Do A on his data (e.g. get h...

How do I embed javascript directly into my ASP.net Custom Control?

I am building my first user control and I would like to package the javascript required for the control with the assembly so the end user does not have to worry about including dependencies. I've followed a tutorial from Scott Mitchell (http://aspnet.4guysfromrolla.com/articles/080906-1.aspx) but I can't seem to get it to work right. H...

How do I refer to the document object of an <iframe> from the parent page, using jQuery?

I'm trying to access the document object of a page that lives in an <iframe> from the host page. In other words, I have a page that has an <iframe> in it, and I want to use jQuery on that page (the parent page) to access the document object of that <iframe>. Specifically, I'm trying to find the height of the <iframe>d document once its ...

How do I preserve dom state in the browser history after dynamic dom manipulation?

Is there a general purpose solution for preserving dom state so that when a user returns to a page by using back/forward, the whole page is in the exact state that they left it? This post asks and answers why the behavior is inconsistent with different browsers and different javascript libraries... http://stackoverflow.com/questions/11...

Javascript custom "event" listener, using prototype implementation OOP

I have been trying to wrap my head around this one, and a lot of tutorials and sites have been suggesting the creation of a separate event object, which seems to be a bit of overkill for just implementing one function to happen at some point in the object. Basically I want to have a custom "onComplete" event to fire when certain methods...

Sorting divs without leaving any gaps.

Is there any way I could resize my div elements without leaving gaps on the page? I think the only option is to calculate the possible generated gaps and move the elements around. Thanks in advance for any idea. Example - (Please click on the cards in order to resize) ...

Extract filename from HTML text using regexp

I have this HTML code (just an example): Sem vestibulum blandit nostra, nullam imperdiet, pellentesque vel wisi sit fusce purus mi, porttitor lorem. Bibendum non phasellus ut ipsum massa sed, interdum per, facilisis facilis luctus fermentum et donec, tristique tristique non.</p> <p align="justify"><a class="nemo" href="http://myserver.c...

What's the fastest way to iterate over an object's properties in Javascript?

I know that I can iterate over an object's properties like this: for (property in object) { // do stuff } I also know that the fastest way to iterate over an array in Javascript is to use a decreasing while loop: var i = myArray.length; while (i--) { // do stuff fast } I'm wondering if there is something similar to a decrea...

Javascript Date to IS8601 format?

Hi, I am learning javascript and I am trying to figure out if there is a simple way to convert a standard formatted Date to ISO8601 format (YYYY-MM-DDThh:mm:ssTZD). Advices? ...

XML Parsing using JavaScript

Hey all, Here's an XML snippet: <appSettings> <add key="val1" value="val2"/> The XML document is loaded in memory, ready to be parsed. How would you get and write the value of "val2" to the web page? Thanks, rodchar Post Comments: I'm getting .selectSingleNode is not a function: <script type="text/javascript"> if (window.X...

best way to store images and then display them

Hi... I have a form that searches a mysql db for whatever the user is after, and returns the results on the same page in a div (using ajax then php to search mysql)... The results are ads, as cars for example, and I want each ad to have a unique image associated with it so that it displays the images next to the ads... Storing images ...

resizeTo in JS gives me "Access is denied" error, how to know if browser is ready?

Hi All, I have a web app, whose UI is written in GWT, where for various reasons I need to resize the active window when the server reports things. To do this I use a JSNI function which uses resizeTo and everything works great. I did a small test and tried sending a few updates from the server and got an "Access is denied" error from the...

Facebook Connect API not populating user data when facebook-logo="true" option is used

Hi folks, I'm working on a Facebook Connect app. I have the Connect button up and running and users can successfully authenticate via Facebook. However, I'm having trouble getting their profile picture and name to display with XFBML. Here is what I'm doing: <script type="text/javascript"> function fb_login_handler() { var userbox ...