javascript

saving html on servers side prior to opening report that use that saved html doesn't work on safari ...

Hi, I've come up with javascript that screen scrape html needed for report and save it on server using ajax call after which I call report that uses previously saved html through pop up. Here is code: function SaveAndPrintHtml(htmlToPrint) { try { $.ajax({ type: 'POST', async: true, ...

Accessing Form elements using ID

This came as a surprise to me but I have a simple form with 3 fields in it. The fields dont have a "name" attribute to it. They instead have an "id" attribute. However. I can still do a var f = document.getElementsByTagName('form')[0]; alert(f.elementID); to access the element. I thought to access form elements in that way, the "name...

How to Check Authenticity of an AJAX Request

I am designing a web site in which users solve puzzles as quickly as they can. JavaScript is used to time each puzzle, and the number of milliseconds is sent to the server via AJAX when the puzzle is completed. How can I ensure that the time received by the server was not forged by the user? I don't think a session-based authenticity to...

asp.net ensure javascript is loaded once only

I've been working in asp.net webforms and I've been making a UserControl that depends on a small bit of javascript which is in an external file. I want to be able to put a reference to the javascript inside the UserControl to ensure that it gets loaded on the page, but the problem is that the UserControl can appear multiple times on a ...

How can I attach event handlers to dynamically-generated DOM elements using jQuery?

I have a <ul> tag that I want to append some <li> tags inside. Example: $('body').append("<ul id='myUL'>").find("ul"); $('#myUL').append('<li id='a'>a</li>'); $('#myUL').append('<li id='b'>b</li>'); I want to give every <li> a different click event. How can I accomplish that? ...

Get full data set, sorted with YUI Data Table with Pagination

I hope I am describing my issue enough.. here goes: I have a YUI data table, get a server side set of records via JSON, and then populates the data. Users can click on the headers to sort the data in three of the 6 columns, (which are using a custom sort function for each column). The sorting is done client-side. When a user sorts th...

Capitalize first letter of text field WHILE typing with Jquery?

I'm looking for an example of how to capitalize the first letter of a string being entered into a text field. Normally, this is done on the entire field with a function or regex onBlur or OnChange, etc... I want to capitalize the first letter while the user is STILL typing. For instance, if I'm typing the word "cat" -- The user should...

jquery appending in the page

hello i'm using ajax to get some information to my page the information received in an array so i use for loop to append them to my html page in this way : for i to i less than my information i++ $('#ul').append("<li>"+info[i]+"</li>"); but i want to add a different .click event to every 'li' tag but i don't want to loop another...

Lightweight JS AJAX library

My friend and I have a site (www.rosasecta.com). It uses a lot of Ajax, but it's all by hand, and it's really ugly and hard to dig through. We want to switch to a JS library, but JQuery, Prototype, and Dojo are to large. We just want a small, compact library that can do AJAX cleanly and some basic DOM selecters. Can anybody recommend one...

how to remove matched tags but leave content with JQuery

I have HTML like this: <div> <div class="a"> content1 </div> content 2 <div class="a"> <b>content 3</b> </div> </div> and I want to get rid of the div's of class="a" but leave their content. My initial attempt was: $("div.a").replaceWith($(this).html()); However this is undefined. How would you do this? ...

jquery how to wrap every fifth element

Hello i know i can do that in the hard way by using for loop or something like that but i'm asking if : there is any simple way to wrap every 5 images in a long list of images Thanks ...

Are string literals objects or not?

Trying to get my JS fundamentals strong. So the question is about string literals. Aren't they Objects? If your answer is 'yes' then my question is why is instanceof returning false? var s = new String s.constructor.toString() function String() { [native code] } typeof s object s instanceof String true s instanceof Object true s ins...

google chrome returns wrong window height?

hi, i have been working on this script http://www.acgunsdcroses.com/agencymeter/. it seems like only google chrome is returning a wrong window height and thus sets the height of the divs wrong, leaving a white space between the red and blue divs. strangely enough this only happens when you load the page for the first time in a new wind...

Questions about capability of Javascript

Many years back, I was told that Javascript was harmful, and I remember being annoyed with endless popup when I right-clicked an image to download it. Now it seems suddenly that Javascript is great, and you can do a lot of things with it to let users have native-like web application experience. I admit I have missed 6-7 years of Javasc...

html-based code editors

Is codepress [ http://code.google.com/p/jquery-codepress-plugin/ ] still the best option for color-coded, line-numbered, tab-catching syntax editing ? Seems like the team developing it has lapsed. Thanks! edit: i'm looking for something i can fork/improve upon/integrate/push back to the community. Thanks again! ...

In Javascript, how do I tell if a user is pressing two keys at the same time?

In Javascript, how do I tell if a user is pressing two keys at the same time? For example, I have drawn a circle in the middle of the screen. I want to move it up while the user holds down the up arrow and right while the user holds down the right arrow. That part works easy. If user holds both the up and right arrows, I want to move th...

jquery anchor detect & prepend

Within an anchor, this works: $(this).prepend('<span>This is the span content</span>'); when trying to do if href equal to, it does not work $('a[href="http://www.google.com"]').prepend('&lt;span&gt;You have selected Google</span>'); ...

JQUERY FIND:FIRST not finding the first Paragraph?

Goal, is to extract the content for the CKEDITOR Text Editor, and then only obtain the FIRST paragraph. For some reason the bellow isn't working... Ideas? Given the following JavaScript: var newTitle = CKEDITOR.instances.meeting_notes.getData(); newTitle = $(newTitle).find("p:first").text(); ...

Iterate over array and combine two arrays

I have two arrays of objects. I would like iterate over each of these two arrays and add a property ("IsPriced"). Then I would like to combine the two arrays into one array. How can I do this in JavaScript (with MooTools is fine, but not with jQuery please)? I really don't know where to begin. ...

is it a good idea to put all javascript file's content into one file to reduce server request and keep at bottom to increase performance?

I use simple javascripts, jquery library and many plugins , should i make one file for all if yes then what we need to "just copy and paste and code from all file into one in needed order" or any thing else need to be considerd. as stated here http://developer.yahoo.com/performance/rules.html#num_http Combined files are a way to red...