javascript

JS validator alternatives to JSLint?

Is JSLint it as far as js validation tools go, or are there others? ...

using jquery selector with ids with comma

I am using MyTableGrid to show an Excel like control in my webpage. The cells are referenced with ids like "mtgIC1_0,2" for table 1, column 0, row 2. Unfortunately, when I try to use the jquery selector with this id $("#mtgIC1_0,2"), it never works. I figured it is because of the "," since it works for any other ids in the page withou...

Does anyone know how to use or modify jQuery Pagination plugin to show nav on top and bottom of page?

I am working with http://plugins.jquery.com/project/pagination and want to have the pagination applied to both top and bottom of the page. Is there any way to make this happen? Edit - Solution Full Code $("#pagination").pagination(data, { num_edge_entries: 2, num_display_entries: 8, items_per_page: 5, next_show_always:...

Changes to selection and range functionality in IE8

I'm having to debug a WYSIWYYG javascript based HTML editor that is failing in IE8. It's only designed for use in IE so that should simplify the solution. Here's the existing code that is failing: function isAllowed() { var sel var obj sel = foo.document.selection if (sel.type != "Control") { ...

Getting static data for Flash app with JSON or XML - caching or not?

Hey, I've flash app and i've static data (like ~18.0KB) for it which aren't changed often so I was wondering how to better get them. The static data may be in XML or JSON. One of my ideas was to put the static data in .js file within a function which would return them in JSON list and the other one was to return them in XML (as I like to...

Suppress Login Prompt from XMLHttpRequest

I am new to javascript but wanted to write a Safari extension to display the badge count of the unread emails in a gmail account. When the user clicks the button it goes to gmail. I got it working and its quite handy. The only thing I can't figure out is how (when the user is not logged into gmail) to suppress my XMLHttpRequest from caus...

Prevent or clear back history with form submission

Hi, I have a small quiz web application to deploy. Basically I have 2 pages, '1) Quiz page' and '2) Result page'. Upon submitting the Quiz form, it will generate the result on the result page for the user. However I need to prevent user from clicking on back button or keying in Backspace on the keyboard. I researched the use of 'locat...

Why does appendChild only work when I remove the docType

When I put any sort of doctype declaration like <!DOCTYPE html >, appendChild does not work.... Why? <form> <script language="javascript"> function function2() { var myElement = document.createElement('<div style="width:600; height:200;background-color:blue;">www.java2s.com</div>'); document.forms[0].appendChild(myEl...

window.event.srcElement doesn't work for firefox?

The following doesn't work for firefox. I'm trying delete the table row on click. Can anyone please help. Many thanks. <INPUT TYPE="Button" onClick="delRow()" VALUE="Remove"> function delRow(){ if(window.event){ var current = window.event.srcElement; }else{ var current = window.event.target; } //here we will del...

What does this type of function mean in javascript?

In the below, I'm confused by the syntax (function (h,j) { }) What does it mean in javascript to have a function sit inside ()'s like that? function myfunc(c, b) { try { (function (h, j) { //do a bunch of stuff }) } catch (e) { myerror(e) } }; ...

Error in crossfading images using <canvas>

I'm trying to crossfade images using the canvas drawImage() method. I'm using jQuery to fadeIn() and fadeOut() the canvas. Here's the code: $("#c").fadeOut(800,function() { //aw and ah are calculated here ctx = canvas.getContext('2d'); ctx.drawImage(img1, 0, 0, aw, ah); $("#c").fa...

Method keys error in Google Chrome

Here is the line of code that I think is the problem and the error that google chrome gives me a.sort(function(a,b){return a-b}); has no method 'keys' In firebug on firefox there is no error. This may be a simple error but I am not at all used to chrome's error console. ...

Menu System Requirement

Hi, menu sample I was wondering if anybody knows of any menu systems (jquery if possible but doesn't have to be) that looks similar to menu sample. It's not really the 2D button look that I am after but more how the sub-menu off the parent menu block is positioned off to the right of the menu. Any help with getting this menu struct...

Mootools Request to change javascript code?

So I am planning on dynamically changing a page's content by fetching it from another page. To do so, I used Mootools' Request class: var tabContent = new Request({ url: 'foo/bar/baz.php', onSuccess: function(data) { $('tab_container').innerHTML = data; } }).send(); In any case, the HTML is fetched fine, and retur...

calling remote folder in div ?

Hi i have to call localhost cakephp made pages using jquery in my another cakephp folder page in div.please suggest any example so that it will be easy to do that. thanks ...

Javascript document.getElementById doesn't seem to work

I have the following code, and the javascript console in chrome says "Can't read innerHTML property of null. Why does document.getElementById('display') turn up empty handed? <!DOCTYPE html> <html> <head> <title>Chat 3</title> <script type="text/javascript"> function showmsg(str){ var disp...

How to get the maximum possible width of a div?

Hello folks, I need to know how one can get the maximum possible width of a div. Generally, a <div>'s width is limited by it's parent, meaning that it can not be larger than a certain amount. How that certain amount can be calculated? I need this to calculate if the text inside the current <div> has overflown, (since the only way to de...

I want to limit 3+ select boxes to only pick one <option> once - what am I doing wrong?

I set up my jQuery like so. It successfully lets me pick an option only once throughout the 3 dropdowns. However, if I remove a dropdown (use the convenient button), an option is forever disabled (greyed out). You'll see what I mean. First, ensure that it works and you can not select the same option more than once. Now, remove and no...

how to print a div using a javascript

hi friend plz send me with some example ...

Removing a particular line from a paragraph using javascript

Hi, I pass a string from one page to another page using AJAX method.This string is available in the data base.It retrieves string along with the whole client page script of the page from where i am retrieving the data.I want the string alone from the rest of the data using javascript.The string which i retrieve from the data base alon...