javascript

HTML/javascript client with a REST backend

I have previously written my web apps with a server side / html template language type design. I am interested in writing a static html client that uses javascript to fetch data from a restful service (ala couchdb). It dawned on me that I could not in one web request get both the static html file, and the json data that is used to popula...

why won't my <div> resize with javascript when I tell it to?

I have a <div> element that contains a table, which I want to resize to the maximum viewport height - 70 px. The reason is that I want the header to stay in one place, and the table to scroll independantly. I can't use iframes for that, since there is complicated javascript interacting with the table. I therefore have to use a <div> and ...

How do you distribute an HTML/Javascript web app?

I've built a web page using HTML and Javascript that acts like a desktop app. I'd like to distribute it to users in the methods they are most familiar with. For Windows users, I think this is an installable application or a "setup.exe" file. My app, however, works perfectly in the browser. Specifically it can be opened in a javascrip...

Convert a mySQL date to Javascript date

What would be the best way to convert a mysql date format date into a javascript Date object? mySQL date format is 'YYYY-MM-DD' (ISO Format). ...

How to simulate a click in javascript?

One of the features is that when a user clicks on something, something happens. How do I simulate this click without just calling the function? ...

Why doesn't this work?

I want to change the value of an element with javascript. <span id="mixui_title">Angry cow sound?</span> <script type="text/javascript"> $("#mixui_title").val("very happy cow"); </script> ...

How do I change the "href" of <a> through Javascript Jquery?

Suppose I have this: <a id="main_link" href="http://feedproxy.google.com/~r/AmazonWire/~5/FN5UZlXKwdY/SalmanRushdiePodcast.mp3"&gt; How do I use Jquery to change the "href" to something else? ...

How do I access the value of a button in a frame from the top level page with javascript?

I have a main page that contains a frameset with some frames. I need to access and set the text of a button inside one of my frames from a javascript method in the main page. I believe its the window.frames that is the issue. It works in IE6 but not in Firefox. Is there something else I can use in place of this to get it to work across ...

How do I get the relative path of a ASP.NET application from client side script?

How do you get an ASP.NET application relative URL from JavaScript? ...

while input has focus

Hi. I have an input field that has a field hint that comes up when focused. The problem is that I am using prototype effects and have the hint Effect.toggle 'ing, and if someone types in the field, then backspaces, the hint gets all backwards. Is there a way to set a var or case or something that can be set while the input has focus? ...

Should javascript code always be loaded in the head of an html document?

Is there a blanket rule in terms of how javascript should be loaded. I'm seeing people saying that it should go on the end of the page now. Thoughts? ...

JavaScript - Validate Date

Hello, I have an HTML text field. I want to validate via JavaScript that the value entered is a valid date in the form of "MM/DD/YY" or "MM/D/YY" or "MM/DD/YYYY" or "MM/D/YYYY". Is there a function that does this? I sort of assumed there was something like isNaN but I don't see anything. Is it true that JavaScript can't validate dates...

How can i process XML doc in javascript bookmarklet?

Can a bookmarklet process the XML result document from a web service once it's displayed in the browser? After calling a web service from the browser, an XML document is returned. I would like to build a bookmarklet to grab some element values from the XML and display them in another window. However, i'm having trouble getting access to...

Customise JQuery EasySlider plugin numeric output menu to use text string instead?

Hello, I'm using this plugin: http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider Demo: http://cssglobe.com/lab/easyslider1.7/02.html Maybe somewhere in here can be altered? if(options.numeric){ for(var i=0;i<s;i++){ $(document.createElement("li")) .attr('id',options.numericId +...

jQuery Selecting the first child with a specific attribute

Hello, I have a form in HTML with multiple inputs of type submit: <form id = "myForm1" action="doSomethingImportant/10" class="postLink" method="post"> <input type="hidden" id="antiCSRF" name="antiCSRF" value="12345"></input> <input type="submit" value="clickThisLink"></input> <input type="submit" value="Don'tclickThisLink"></input> </f...

Javascript: Write Console.debug() output to browser?

I need to be able to take any JSON data and print the key/value pairs. (something similar to print_r() in PHP) Is this even possible with javascript? ...

Find the exact height and width of the viewport in a cross-browser way (no Prototype/jQuery)

I'm trying to find the exact height and width of a browser's viewport, but I suspect that either Mozilla or IE is giving me the wrong number. Here's my method for height: var viewportHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; I haven't...

Mozilla Rhino: Different ways of adding Java object to scope

I've got this piece of Java code with embedded Rhino (irrelevant bits omitted): Context cx = Context.enter(); Scriptable scope = cx.initStandardObjects(); scope.put("foo", scope, Context.toObject(foo, scope)); ScriptableObject.putProperty(scope, "bar", Context.javaToJS(bar, scope)); where foo extends ScriptableObject and bar is just...

Javascript - Remove references to my object from external arrays

I have a problem with dereferencing a Javascript object and setting it to NULL. Here, I have a Folder implementation that supports recursive subdirectory removal. Please see my comments to understand my dilemma. function Folder(name, DOM_rows) { this.name = name; this.files = [].concat(DOM_rows); this.subdirs = []; } Fold...

Can I get the location of where a JavaScript library is loaded from, from within the script?

Lets say I have a page with this code on it on www.foo.com: <script src="http://www.bar.com/script.js" /> Can I write code from within script.js that can check that it was served from bar.com? Obviously document.location.href would give me foo.com. Thanks! ...