javascript

Dynamic deep selection for a JavaScript object

With a single property this is fairly easy: var jsonobj = { "test": "ok" } var propname = "test"; // Will alert "ok" alert(jsonobj[propname]); But what I want to do is use a nested property: var jsonobj = { "test": { "test2": "ok" } } var propname = "test.test2"; // Alerts undefined alert(jsonobj[propname]); I...

Math.random() question

What is the precision of JavaScript's Math.random() function? Thanks! ...

what am I missing in this RegEx?

I'm trying to create a JavaScript Regex to test for: a valid # between 0 and 99.9 (where only a single decimal digit is allowed) e.g. 3.45 is not valid. so, blank is ok, any integer between 0 and 99 is ok, and a decimal value is allowed. I have this so far, but it is allowing values like 3.45 to pass: $^|$[0-9][0-9]?^|$[0-9][0-9]?.[0...

jquery dialog: drag dialog at any point.

Is there an trick to make a jquery dialog be draggable at any point? (i mean not only in the title bar) ...

embedding a website inside a modal box on a different domain

I need to embed an iframe on different domain, that when click opens a modal box using fancy box. It would work something like this. user clicks image Once click loads a modal box(fancybox) that holds the iframe I need to do this because the fancybox needs to take up the majority of the screen 960x700 How would I do this? ...

How to build this layout with CSS?

Hello, I'm not new at CSS, but this is problem for me and I can't solve it. I need to build layout as below: Divs that are at the bottom and at the top have fixed heights. The one in the center have to be exacly in the height of PAGE HEIGHT - DIV 1 HEIGHT - DIV 3 HEIGHT or in some cases smaller. Also it have to had this size setted b...

Method callback not being hit

I swear this was working last night which was why I was able to get to bed at 1am ;). I come into work this morning and now it never gets to the callback of FB.api. The FB.api is an async Facebook JS call...but regardless this was working fine last night and I don't think it's a facebook server (end point) issue. function ...

jQuery or Javascript continuous counter (countup)

Hi guys, Looking for a script that I can ideally enter a starting number and a start date, which then continues to increment based on a rate I set e.g. 1 per second. The script would ideally calculate what number it should be on based on the difference between the current time and start time. It's meant to look like it's showing a live...

Dojo caching issue in Spring

I am having an issue where dojo seems to be caching html and then not properly redisplaying it. If I call this function once it works fine, and it works on all subsequent calls if the parameters are unique. If I call it twice with duplicate parameters then essentially nothing happens. I'd appreciate any help. function findN...

jQuery gallery doesn't work in IE.. but DOES after refresh?

I am using jquery galleria like so: $(document).ready(function() { Galleria.loadTheme('js/galleria/themes/classic/galleria.classic.js'); $('#galleria').galleria({ image_crop: true, /*transition: 'fade',*/ data_config: function(img) { return { description: $(img).next('p').html(...

Embedding inline JS script instead of making an AJAX request. Why?

I noticed that some websites (for example: apple.com or disqus.com) don't send AJAX request to load, for example, live search results. Instead they attach new JS script, that holds all results in a variable. To be more specific. If you go to apple.com and type "test" into the searcher. It won't send an AJAX request to get the results, i...

Javascript Helper Library

Hello all, I've been assigned a project to create a js library that serves as a starting template for all of my company's websites. The idea is to include some standard things that we do so that we aren't reinventing the wheel every time. I've made a good bit of headway thus far, but I cant help but feel like I could be organizing thi...

converting javascript code into html output?

I can use javascript to get html tags and divs to appear but I want to put some text in a div. this.buildDomModel(this.elements["pans"], { tag: "div", className: "panel", id: "tabs", childs: [ { tag: "div", id: "page_button", className: "box", childs: [ ...

is it posible to call asp fuction inside javascript fuction?

is it possible to call asp function inside java script function? eg <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Import Namespace="System.Xml" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <script ...

And I thought I understood scope...

Can someone please tell me why the last logging of 'x' equals 0 and not 1. I thought because it's declared outside of a function it has global scope and then in the function it's value is set to 1 and that value would remain as it's a global? I know the first 'x' value inside the function is a global as any variable declared without the ...

How to put php inside javascript?

Hi, How to put php inside javascript? I try (but its not working): <?php $htmlString= 'testing'; ?> <html> <body> <script type="text/javascript"> var htmlString=<?php echo $htmlString; ?>; alert(htmlString); </script> </body> </html> tutorial that I use for that parpose: http://web-design.lovetoknow.com/...

workaround: javascript dictionary which takes objects as keys

Hi, I read a few questions and answers about javascript dictionary implementations, but they don't meet my requirements: the dictionary must be able to take objects as keys the values must be accessible by the []-operator So i came up with the idea to overwrite the "valueOf"-method in Object.prototype, as follows: Object.__id__...

jQuery Cycle - IE not loads the image at once (blinking occurs)

Hello, I'm having problem with jQuery Cycle plugin in IE8 (and other IEs as well) I have 3 slides which contains Title, Description + Image. The problem is that in IE8 the image is "blinking" / not loading at once (the bottom is cut off for a while is it displayed fully). Before I had problem with the white BG under the slider, but I...

Help with auto-resize of background image

Hi, Is there a way to automatically resize the background image of an element. For example, in my html, I would like to my links to be have a background image. The image has slanted left and right border and round top corners. One would normally specify the width of an anchor element to accommodate the background image. My problem is...

JavaScript: Confirm dialog box that shows value from a text box

Hi. Is there a way to have a confirm dialog box display the value a user typed in a text box on a form? (For example, if the user types 100.00, I'd like the dialog box display a message something like, "Confirm Amount. Click OK if $100.00 is the correct amount.") ...