javascript

JavaScript: create a string or char from an ASCII value

In JavaScript, how can you get a string representation of an ASCII value. e.g. how to turn 65 into "A"? ...

How can I clear HTTP headers for AJAX GET calls?

I have developed a solution that relies on an AJAX call to retrieve information and update the client page every 10 seconds. This is working fine, but I am concerned at the scalability of the code, given the number and length of headers being passed from client to server and back again. I have removed a number of redundant headers on the...

JavaScript file per view in Rails

As per 'unobtrusive JavaScript' recommendations I want to separate my JavaScript logic into separate files. However I don't know how to organize them. Should I: Just throw all application javascript into Application.js file and load it with layout page? This is simple approach but I will end up with a bloated Application.js. Some use...

How to know if url is already bookmarked

I am adding bookmark from code. Now in Firefox if user already added the url as bookmark he should not be able to bookmark it again. How can I do it? For now every time a new bookmark is getting created. ...

How can I create a class without defining it in javascript

Hi all, I have a class at server-side like this : public class Address { public Address(string countryCode) { this._CountryCode = countryCode; } private string _CountryCode = string.Empty; public string CountryCode { get { return _CountryCode; } set { _CountryCode = value; } } } ...

What's the different between ASP.NET AJAX pageLoad() and JavaScript window.onload?

I'm working with ASP.NET AJAX and want to understand the difference between these two snippets: function pageLoad(sender, eventArgs) { } and window.onload = function() { } Do they act the same? Or is one called before the other? Or will one be called automatically and the another not? ...

Can you do this using jquery?

Is it possible to do this from within a class? $("#" + field).click(this.validate); So basically I want to pass a function of the object that should be executed whenever something is clicked. Also, if there are more than 1 instances of this object, then the correct instance (i.e the one which runs this code for the given field) sho...

Why is my javascript function not found by the page it is embedded in?

I have a page that has a simple javascript in the header portion of the page: <script type="text/javascript"> function doLogout() { var conf = confirm("Really log out?"); if (conf === true) { //changed == to === for boolean comparison $.post("logout.aspx"); } } </script> It uses jQuery ...

Need help understanding jQuery .val() function

alert("data going into $hidden: " + selected.data[1]); hidden.val(selected.data[1]); alert("data now in $hidden: " + $hidden.val()); What would be a reason that $hidden.val() in the last line above would return undefined? I have verified that selected.data[1] contains an integer value. Edit #1: Some additional context per comments:...

How to use draggable sections like on iGoogle?

When viewing iGoogle, each section is able to be drag-and-dropped to anywhere else on the page and then the state of the page is saved. I am curious on how this is done as I would like to provide this functionality as part of a proof of concept? ...

What does the "?:^" regular expression mean?

I am looking at this sub-expression (this is in JavaScript): (?:^|.....) I know that ? means "zero or one times" when it follows a character, but not sure what it means in this context. ...

How do I insert a new TR into the MIDDLE of a HTML table using JQuery?

I know how to append a new row to a table using JQuery: var newRow = $("<tr>..."</tr>"); $("#mytable tbody").append(newRow); The question is how do I create a new row that precedes some existing row. ...

How can I apply jQuery statements to elements that are loaded in runtime?

I have a web page with one button and one div If you click this button that will load another button into the div using jQuery I found that the new button -which is loaded in runtime - will not be effected by other jQuery statements. how can I apply jQuery statements to elements that are loaded in runtime? I wish It is clear! if not ...

JavaScript Object Method Chaining: useful?

So... messing around in JavaScript with an idea that's new to me, having methods of an Object return the Object of which they are methods; this then leads to chainability. My question, then: how can this be useful? I threw this together to test the fundamental workings: <script> MathChain = function() { this.pass = function() ...

How to navigate href in anchor tag via JavaScript

Is there an easy way to have JavaScript mimic a User clicking an anchor tag on a page? That means the Referrer Url needs to be set. Just setting the document.location.href doesn't set the Referrer Url. <script> $(document).ready(function () { $("a").click(); }); </script> <a href="http://example.com"&gt;Go here</a> This doesn't...

Submitting HTML Forms with Slider as input (WebFX)

How can I submit the value of this slider to a CGI application (like you would a check box)? Not sure if the input tag for the slider is messing something up? <div class="slider" id="slider-1" tabIndex="1"> <input class="slider-input" id="slider-input-1" name="slider-input-1"/> </div> ...

How to — callback functions

Hi guys. I have a big problem writing a small piece of code using JS/jQuery (don't know which of these is causing the problem). Anyhow, here we go: $('#themePicker').unbind().click(function() { var t = $(this); modalwindow2(t, function() { console.log(1); }, function(w) { console.log(w); }); return false...

Attaching chained methods to collections of elements in JavaScript

This is—at least at the moment—purely experimentation, but I'm curious: is there a way to attach methods (via prototyping) to collections of elements? I've tested the following code: <div>a</div> <div>b</div> <div>c</div> <script> NodeList.prototype._ = function(s) { for (x = 0; x < this.length; x++) { eval('this[x]' + '....

Submit name value pair from javascript?

Can JS submit name/vale pairs through a document.testform.submit(); ? or does it have to be submitted through the html tags, for example <INPUT TYPE="text" NAME="inputbox1" VALUE="This is such a great form!" SIZE=50><P> ...

html value set from javascript?

<script type="text/javascript"> var p = s.getMaximum(); </script> <form action="/cgi-bin/Lib.exe" method="POST" name="checks" ID="Form1"> <INPUT TYPE="text" NAME="inputbox" VALUE="VAR P FROM JAVA SCRIPT HERE?" ID="Text1"><P></form> Possible to pass the javascript value 'p' as the value of input form? Thanks. ...