javascript

How can I convert a Guid to a Byte array in Javascript?

I have a service bus, and the only way to transform data is via JavaScript. I need to convert a Guid to a byte array so I can then convert it to Ascii85 and shrink it into a 20 character string for the receiving customer endpoint. Any thoughts would be appreciated. ...

JavaScript problem toolbar=no

I have a simple logon page. When the user is validated, the window navigates to a new page. The javascript is window.open('http://www.google.com',"mytest",'toolbar=no'); My expectation is that when it navigates away from our logon page and opens the google site that the back button would be disabled. But it's not. Does anyone...

How to set the Content-Type header using JavaScript

Hey, How can you set the Content-Type header to "application/x-www-form-urlencoded; charset=UTF-8" using JavaScript? I need to do this so I can view a form with french characters without generating errors. Thanks ...

javascript validation error

here's my code, which says error when i run it through w3.validator.org. for (var i = 0; i < CheckBox.length; i++) error message - character "<" is the first character of a delimiter but occurred as data how do i fix this? ...

ASP.NET: How to "reset" validation after calling Page_ClientValidate

I have an ASP.NET page with a jQuery dialog that is displayed to change some data. I am setting up the jQuery dialog so that when the user clicks the OK button it calls ASP.NET's Page_ClientValidate('validationGroup') via javascript, finds all the invalid controls and changes their CSS class. So here's the scenario: the user opens the ...

alternatives for erb to make application.js dynamic

To make application.js more dynamic, I create javascript_controller and rename public/application.js to app/views/javascripts/application.js.erb But <%= … %> does not look very good in javascript, are there any better templating engines for this task? ...

Is there a benefit to defining variables together with a comma vs separately in JavaScript?

Reading Crockfords The Elements of JavaScript Style I notice he prefers defining variables like this: var first='foo', second='bar', third='...'; What, if any benefit does that method provide over this: var first='foo'; var second='bar'; var third='...'; Obviously the latter requires more typing but aside from aesthetics I'm wonder...

How to pass data using jQuery's ajax methods on click events / links?

Using 'old school' javascript you would put the ID as the parameter in an inline function call (onclick="my_function(28)" or similar), with the ID provided by your server-side code. Using 'new school' javascript, the function call is abstracted from the element, so how to pass the ID? My guess is: <a id="28" class="do-something" href=...

Waving text on canvas

How could I make waving text on a canvas element similar to what is found on this page? ...

JavaScript - Loop within a function to alt color table rows

I have a query building form built in php. The results of the query are returned and placed in two different tables one above the other. (table id's are results, and results2) Each record returned builds two tables to display its data. (Soon to be three) I'm using the following code to change the class tags of my 's to provide alterna...

How do I create a custom event class in Javascript?

How do I create a custom event class similar to ActionScript? What I mean by that is a class that I can use to fire off my own events, send the necessary data. I don't wanna use third-party libraries like YUI or jQuery to do it. My goal is to be able to send a event that looks like this. document.addEventListener("customEvent", eventHa...

Is it possible to create or exchange Javascript properties on access

I would like to have some sort of lazy initialied object properties in javascript and would thus want to somehow overload the property read and write access i.e.: var someval = myobj.lazyprop; // invokes myobj.get("lazyprop"); myobj.lazyprop = someval; // invokes myobj.set("lazyprop",someval); where myobj is some object I provide ...

Javascript: Validate that each combo box selection is unique

I have five combo boxes. Each one has a different name, but the possible values for each are the same: 1-5. I would like to use Javascript to validate two things: that each value is selected only once. For example, if the value of "cboCircle" is "1" then the value of "cboSquiggle" cannot be 1, and so on. that each selected value i...

innerHTML alternative for retrieving contents of page?

I'm currently using innerHTML to retrieve the contents of an HTML element and I've discovered that in some browsers it doesn't return exactly what is in the source. For example, using innerHTML in Firefox on the following line: <div id="test"><strong>Bold text</strong></strong></div> Will return: <strong>Bold text</strong> In IE,...

Using Javascript to change the method/function an HTML element calls.

I was wondering if its possible to use Javascript to change the function/method that an HTML element calls. Example: <input type="button" id="some_id" name="some_name" value="A Button" onclick="someFunction()" /> I now want to use Javascript to change the method/function called on the onclick event to another function has displayed ...

How to trigger click on page load?

I'm looking for a way to automatically "click" an item when the page loads. I've tried using $("document").ready(function() { $("ul.galleria li:first-child img").trigger('click'); }); but it doesn't seem to work? However, when I enter $("ul.galleria li:first-child img").trigger('click'); into Firebug's console and run the script...

Is it really not possible to add actions to this shortened if statement in js?

(category=="Villor/Radhus mm")?byId("nav_sub_villor").style.display='block' : byId("nav_sub_villor").style.display='none'; I would like to call a function if the statement above is true... But it doesn't seem possible... Just want to be sure it is not possible, does anybody know? ...

Scroll bar problem when applying JQuery UI effects to text

I'm trying to use JQuery UI to make a block of text draggable (and later, droppable and resizable). The problem is that all of the JQuery UI documentation examples act on objects that have an explicitly specified CSS width and height. If you do something like this: <script type="text/javascript"> $(function() { $(".draggable").draggable...

'this.get_element() is undefined' when using UpdateProgress ASP.NET AJAX

I'm getting a JavaScript error in the ASP.NET AJAX framework when using the UpdateProgress control. Details: The UpdateProgress is inside the UpdatePanel. Firebug error information: this.get_element() is undefined Sys$UI$_UpdateProgress$_startRequest()ScriptRe...373681250 (line 1931) anonymous()ScriptRe...373681250 (line 61) How d...

what browser is document.layers sniffing?

I am looking at some JS code from the 20th century, and they are using document.layers in code that is trying to get the current key code. What browser are they sniffing for? i am about to replace the code with something like this: var fn = function(event){ event = event || window.event; var code = event.charCode || event.keyCode; ...