javascript

How to get JavaScript caller function line number? How to get JavaScript caller source URL?

I am using the following for getting the JavaScript caller function name: var callerFunc = arguments.callee.caller.toString(); callerFuncName = (callerFunc.substring(callerFunc.indexOf("function") + 8, callerFunc.indexOf("(")) || "anoynmous") Is there a way to discover the line number from which the method was called? Also, is there ...

Why is my for loop stopping after one iteration?

Racking my brains on this one. I have the code below: the first stages of a JavaScript game. All the objects are well-defined and I'm using jQuery for DOM interaction. The puzzle is created with the following JS code: var mypuzzle = new puzzle("{solution:'5+6+89',equations:[['5+3=8',23,23],['5+1=6',150,23],['5+3=6',230,23]]}"); Howev...

How to copy html source of a link to the clipboard and parse as a link in Lotus Notes?

How do you copy the html code of a link to the clipboard and parse it as a link in Lotus Notes? For example, in Javascript put <a href='http://www.stackoverflow.com'&gt;StackOverFlow&lt;/a&gt; into clipboard, and then parse it as a link in Lotus Notes while writing a new email. It should only show a link as StackOverFlow in new message....

javascript form validation suddenly stops working

in my code i called a javascript function onsubmit of a form and inside the function making validation to my fields by using formname.fieldname.value and it works fine but suddenly it doesn't work display me an error "formname is not defined". Thanks in advance ...

Is debugging JavaScript as easy as debugging a C++/C#/Java application?

Is debugging JavaScript as easy as debugging a C++/C#/Java application (given the best IDE available), or are the current tools much more limited and less user friendly, making debugging a headache? ...

Random number after js file include

Hello, I have a problem with a page that includes two js files. In firebug it shows that every time the page loads those two files get included with the prefix ?_=someRandomNumber I don't know where that random number is generated from and I guess it is the reason the files are not being cached and are downloaded each time the page is ...

Does JavaScript code suffer severely from cross-browser compatibility issues?

Is it in general very hard to port JavaScript code to another browser platform? ...

Class inheritance in Prototype.js and arrays

I'm using the Prototype.js (from www.prototypejs.org) library to create classes which are extended by subclasses. I'm having trouble using arrays within instances of these classes though. I've made an example to illustrate this: var SuperClass = Class.create({ initialize: function(id) { this.id = id; } }); var SubClass = C...

jQuery Validation - Using validation on click, not on submit

I'm using (or trying to) JQuery Validation with WebForms/html. I have, basically (simplifying the real html, showing only the elements): <input id="txtEmail"/> <input id="txtTicketID"/> <a id="create" href="#">Create a new ticket</a> <a id="find" href="#">Find this ticket</a> The javascript for validation/action is here: $(function(...

What does @cc_on mean in JavaScript?

Sometimes I see @cc_on in JavaScript. What does it mean? ...

How can I return variable from the correct JS scope ?

Hey, I'm doing some development using JS unde Adobe AIR. What I want to do is create a request to a remote website (for authentication for example). The problem is not AIR related, it's a JS thing I can't get right. What I want to do is to retrieve the request body but if I just return the "str" var it shows "undefined". I've tried to...

invalid index error in javascript

Hi, we have a website where the users occasionally gets invalid index when trying to move some items from one list box to another. when we try to do the same thing it doesn't happen. so we are not sure how that is happening. It seems like the script is trying to access an element in the array that doesn't exist or something like that. I...

Custom JavaScriptConverter for DateTime ??

I have an object, it has a DateTime property... I want to pass that object from an .ashx handler back to a webpage via AJAX/JSON... I don't want to use 3rd party controls... when I do this: new JavaScriptSerializer().Serialize(DateTime.Now); I get this: "\/Date(1251385232334)\/" but I want "8/26/2009" (nevermind localization....

How to return the result from JSONP call outside the function?

I have the following function which works great, i used JSONP to overcome cross-domain, wrote an http module to alter the content-type and didn't append a callback name in the url. function AddSecurityCode(securityCode, token) { var res=0; $.ajax({ url: "http://localhost:4000/External.asmx/AddSecurityCode", data: { securityCode: JSO...

Auto fit width of li to text?

Is there anyway possible to auto fit the width of an <li> tag to the width of the text it contains using CSS? I'm designing a website that uses a custom CMS (and I don't have access to the code), so I'm limited in options as far as design goes. Javascript solutions that would work on an <li> tag without having to edit any of the list ...

How do you set file input to nothing with JavaScript or HTML?

On the site I am developing, I have a file input that users can upload files from. It uses "Ajax" (not really) to send the file to a php file that is bound to an iframe. My question is that Firefox automatically fills in the file input element. Is there a way I can give users the option of clicking the submit button without sending the f...

How to add a row below the currently selected row (based on a dropdown input) using jQuery?

I have a table with a bunch of rows. In the last column of every row, there is a dropdown. When the dropdown changes, I need a new table row to appear below the row where the user selected the dropdown item. However, I also need the new row to have different data depending on what was selected in the dropdown. Is any of this possib...

jquery masking/alerting problem in IE

I've got a table an input box that has a money input mask on it. I haven't had any problems with it yet, but now it doesn't seem to be working properly and I can't get anything to alert from it. All of this is an internet explorer problem. Works fine in FireFox. In firefox the mask works right as it only allows numbers and at a fixed...

Send JSON with AJAX

Is there anything special I have to do to a JSON object before I send it with AJAX? My code looks like this: runAjax(JSON.stringify(data)); } function runAjax(JSONstring) { ajax = getHTTPObject(); var params = "?data=" + JSONstring; ajax.open("POST", "createtrip.php", true); ajax.setRequestHeader("Content-type", "app...

What is the best way of "overriding" the .toggle() function of jquery?

I want to change the toggle function so that it changes the text of the link to say "show/hide" or "expand/collapse". The function definition and call in classic JS would be: function myToggle(expandText, collapseText, id,o){ // expandText: "expand", "show", "display" // collapseText: "collapse", "hide" // id: the id of the di...