Search javascript

136304 results
2

votes
2

answer

Yesod javascript formatting

I am working on debugging some javascript code that is generated in Yesod. Yesod generates javascript files with each function on one line which makes it impossible to set break points within the function. Is there a way to change this behavior so that the javascript preserves formatting for debuggi...
Steve Severance
2

votes
1

answer

JavaScript Array weird initialization

I've stumbled upon something strange.... Maybe someone can try explaining the difference between these two: var a1=Array(2); var a2=Array.apply(null,a1); console.log(a1); console.log(a2); console.log(a1[0]===a2[0]); notice the items are equal but the console log of the arrays looks different (on Chr...
srfrnk
2

votes
2

answer

Digital signature with Javascript

So I'm stuck with this problem: IE Edge no longer allow applets, activeX, etc. , and I have this applet that is used for digital signature, the idea is to extract the private key from the KEY file in the client side, in that way the private key never leaves the client's computer, that is a requirem...
Alfredo M
37

votes
3

answer

Scroll event listener javascript

Is there a js listener for when a user scrolls in a certain textbox that can be used? Kinda like onclick except for scrolling. I saw HTML5 event listener for number input scroll - Chrome only but that seems to be for chrome only. I'm looking for something cross-browser.
Kpower
2

votes
3

answer

javascript equivalent to sed

I'd like to trim string, eg. Pencil (4,99 USD) to just a bracket numeric value: 4,99 I now a bit about regular expressions in sed, so I'd do that like this: sed 's#.*(##' | sed 's# USD.*##'. But how should I use any regular expressions in javascript replace function?
Greg Witczak
6

votes
1

answer

Cordova JavaScript Plugins

I am beginning to understand the way Cordova works internally more and more; one thing I continue to struggle with is the format of the JavaScript plugins however. I am used to writing my JavaScript as follows (which is the standard convention, as far as I am aware): (function () { var version = 'EX...
keldar
5

votes
4

answer

Javascript Object literal

Here is my object literal: var obj = {key1: value1}; How can I add: {key1: value1,value2,value3} to the object?
user760912
2

votes
0

answer

Javascript Order of Events

just wanted to ask a quick question if I may regarding a simple JavaScript function I've cobbled together. This is not my forte at all so it's taken me some time just to get it working, but since I don't have that much of an understanding on the flow of things, I do have a question which I'm struggl...
Paul Wilson
2

votes
1

answer

JavaScript object creation methods

I've been searching around Stack Overflow, and the web in general, for a decent explanation of something I'm seeing in some legacy JavaScript. So far I haven't had much luck, so I've decided to take the extreme measure of actually posting a question. :-) The code isn't super old, but it pre-dates...
Bob FiveThousand
2

votes
5

answer

Unterminated string constant JavaScript

Unterminated string constant hello I have a php code which is: $bodier .= 'setInterval('updateClock(\'$date2\',\'clock$x\')',1000);'; I use it like this:
user1627537
3

votes
1

answer

Javascript syntax []() and ()() [duplicate]

This question already has an answer here: How does this object method definition work without the “function” keyword? 2 answers I'm having trouble understanding these javascript syntaxes. In the block of code below, on the second line. The square bracket is quickly followed by a round bracket o...
Badmus Taofeeq
4

votes
2

answer

JavaScript functions not defined?

For some reason, Firefox is throwing 'function not defined' errors at this piece of JS: $(function() { // on document ready function updateAlerts() { $.ajax({ url : '/check.php', type : 'POST', data : { method : 'checkAlerts' }, success : function(data, textStatus, XMLHttpRequest) { var response = $...
iamandrus
3

votes
4

answer

Attaching events in JavaScript

As comment to one of the questions here a commenter wrote (emphasis mine): ... By using an inline 'onclick' you are doing a similar thing, but it is harder to maintain and more prone to issues. The JavaScript community as a whole has been moving away from inline JavaScript for a while now. This was...
R0MANARMY
2

votes
4

answer

Number formatting in JavaScript

I am trying to create a JS script to format numbers using , separator but something is going bad in the logic implementation. I am changing values of arr1 here. This is the JS code I am using this time - var arr1 = [1,2,3,4,5,6,7]; arr1.reverse(); var i = 1; var tempArr = new Array(); for( i; i ,2...
Trialcoder
3

votes
3

answer

Counting sundays in JavaScript

I have this little riddle that I wanna solve it is bugging me this is the riddle: 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occu...
Nick
3

votes
1

answer

Code studio javascript

So I'm basically making an savings account system. A user can set up an account and start with a balance of 0 the withdraw and deposit money whenever they want. It works perfectly the first few times but then it gives me the RangeError either when I try logging in or out. setScreen('LogIn'); var ba...
Soleil Santana
2

votes
2

answer

Javascript dynamic rows column

I am new to javascript. I have a table of content which I want to rearrange its row and column based on user's window size using window.onresize. window.onresize = function () { var w = window.innerWidth; var nocolumn = Math.floor(w / 252); if (nocolumn == 0) { nocolumn = 1; } var table = document.g...
Ren Fa Kay
4

votes
1

answer

Javascript synchronous AJAX timeout

My Javascript needs to send some data to a server when the page closes, which I currently do with a synchronous AJAX (SJAX?) request in window.onbeforeunload. The problem with this, of course, is that if my server takes too long or the network connection dies, the browser freezes. From what I've rea...
igul222
5

votes
4

answer

javascript window.open doesn't work

I want to use window.open to open a window to one of my JSP file. But the browser keeps showing connecting... And even firebug stops working every time I click the text. Neither the p nor the input tags work, but when I use a href to link the JSP it can link to the file: Sample JSP Page function ope...
ethan
2

votes
1

answer

Javascript 2014-08-19

Does anyone know why the day 08/19/2014 in Javascript return the day 08/18/2014? > new Date(2014, 9, 18) Sat Oct 18 2014 00:00:00 GMT-0300 (BRT) > new Date(2014, 9, 19) Sat Oct 18 2014 23:00:00 GMT-0300 (BRT) > new Date(2014, 9, 20) Mon Oct 20 2014 00:00:00 GMT-0200 (BRST)
Carlos Maniero
3

votes
1

answer

Javascript Changing Firefox Proxy

I am trying to do what the title says and have been searching on here for a while now and I found a solution which looks viable. Only issue is the requre() function is not recognized. Now I am unsure, do I need to update java, firefox, or iMacros to fix this. As well I am not sure if I made an error...
Michael Miner
1

votes
3

answer

Javascript callback functions execution

I'm not sure the correct term for this. But I want to write a function that accepts another function and execute it. For eg. function test(data, aFunc) { var newData = data + ' Shawn'; aFunc.call(newData); } test('hello', function(data){ alert(data); }); Data is supposed to contain 'hello Shawn' str...
Shawn Mclean
5

votes
2

answer

Javascript infinite prototype chain

I am using the following test code: function Test() { } Test.prototype.MyMethod = { a: function() { }, b: function() { } } And to run it I'm simply doing: var test = new Test(); console.debug(test); In the firebug console, I expand the object that was printed and look inside of __proto__: In there...
opl
2

votes
1

answer

Maddening IE javascript problem?

I have a page that uses a bit of jQuery and an effect called 'kwick' - in my sample page hosted at http://www.batsumaru.com/main.html it worked fine in all browsers, no problem. But when the actual code was produced at http://www.batsumaru.com Internet Explorer shows a script error (object does not...
2

votes
1

answer

javascript clock with timezone

would like to show time on my site with seconds counting, like this one. I know there is a lot of similar questions, but I was not able to find out a solution that would work for me. Problem is, all those javascript clock that handle timezone are done by offset. I am however using django timezones:...
Lucas03
2

votes
2

answer

dateformat validation in javascript?

function isValidDate(sText) { var reDate = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/; return reDate.test(sText); } function validate1() { var oInput1 = document.getElementById('txtdate'); if (isValidDate(oInput1.value)) { alert('Valid'); } else { alert('Invalid!'); } } I had wr...
santhosha
4

votes
2

answer

Defining classes in JavaScript

I have been reading up on object-oriented JavaScript. This is a link that I have been reading, Introduction to Object-Oriented JavaScript. However, I have also been reading the book Practical CakePHP Projects. I am trying to figure out why do they use class to define the class? From what I have read...
j.jerrod.taylor
3

votes
2

answer

Inheritance with javascript

I have an account class in javascript. That is my parent class. depositaccout and savingsacount are the children. all this classes are in external javascript files. the calsses are: function account(accountNum, type) { this.accountNum = accountNum; this.type = type; } function depositAccount(account...
user2674835
4

votes
1

answer

Is Javascript “caching” operations?

I was implementing the Levenshtein distance function in Javascript, and I was wondering how much time it takes to run it with Wikedia's example ('sunday' & 'saturday'). So I used console.time() and console.timeEnd() to determine the time spent for the function execution. for (var i = 0; i < 15; i++)...
Seblor
1

votes
10

answer

JavaScript before jQuery [duplicate]

Duplicate: What are some of the pros and cons of using jQuery? Should I avoid using a JavaScript library while learning how to write AJAX client code? I've read it so many times... 'I'd learn JavaScript before learning something like jQuery' - but is this really necessary for every situation? Sure,...
6

votes
4

answer

Javascript Remove Braces

I have the string '{Street Name}, {City}, {Country}' and want to remove all braces. The result should be 'Street Name, City, County'. How do I do that?
Sinal
2

votes
3

answer

Javascript and [bind] implementation?

I read a bit about the bind implementation in JS ( from John Resig's book ) : It looks something like this : ( jsbin) #1Function.prototype.bind = function () #2{ #3 var fn = this, #4 args = Array.prototype.slice.call(arguments), #5 object = args.shift(); #6 #7...
Royi Namir
5

votes
6

answer

Javascript: onrefresh or onreload?

I want an event handler that fires when the user hits reload. Is onrefresh or onreload the correct handler to add to ? Also, will this even fire before or after onunload? Are there an browser inconsistencies? Thanks.
Sam Lee
13

votes
1

answer

“”.split(“ ”) in SO's javascript

I've seen a lot of idioms, most of them clever and logical once explained. But while I was looking over SO's javascript to get some ideas about good interface design I saw the following line: initTagRenderer(''.split(' '), ''.split(' ')); Which really threw me for a loop. Obviously, they initialize...
bkconrad
2

votes
2

answer

browser (javascript) resource problems

I've lately been running into odd issues, which I'm starting to think are related to resource starvation in the browser. In FF: I'd been testing one of our web apps and suddenly things that should disappear after a couple seconds stopped disappearing. I tracked back to setTimeout just flat out refus...
aepheus
2

votes
3

answer

Using JavaScript in Ant

I am having issues using the tag in Ant and I am hoping someone can help. I want to use JavaScript in my Ant build.xml. Something like the following: * Unfortunately this only displays and error: build.xml:4: Could not create task or type of type: script. I have located the required jar file (js....
ah414
1

votes
4

answer

Javascript function call

How to call more than one javascript function on the window's onload event? For Ex, window.onload=MyFunc(); //Single Function But what if there are more than one functions to call on the window's onload event...
Aditya Singh
1

votes
7

answer

Javascript reset loop

i have a little problem with my javascript code, i build a function that add filed by a qty that the user choose, here is the function $(document).ready(function() { $('.qty').change(function(){ for (var i=0;i
Bonik
2

votes
3

answer

slidetoggle in pure Javascript

As you might see I have fixed a kind of text box that will pop up when someone is hovering over that image, but honestly I want a slide-up effect that gone up slowly. Must be completely in pure JavaScript (no jQuery please!). Anyone knows how I can do that. function show(myText) { var elements = d...
Front-end Developer
2

votes
2

answer

javascript inside php

How can i write a javascript alert inside php ? For example if i want to popup a javascript alert in this if condition how I can do it ? if(isset($_POST['downloadkey'])){ $key = $_POST['downloadkey']; if($key != $data['download_key']){ echo 'Your key is wrong.'; echo ' alert(Your downlaod key is wro...
Faryal Khan