But in my actual implementation, I have over 20 different elements
which need to be positioned using this method. When I made the code, I
found that my CPU would be at 100% for even trival events such as
mouseover() and mouseout()
But in IE 8 it takes very long to hide? I don't like to set it in CSS because if javascript is turned off people can still login as it is visible... is there anyway to make it faster ?
I want to start out by entering an investment amount as well as an interest amount. Then I want to find out how many years it would take to become a millionaire, using each cycle through a looping statement as one year. What would be the best way to do this?
We are using JQuery for one of our software projects, and it's a very nice library. It's making things far easier. We are also using the Validation plugin, which is working wonders for form validation.However there's one wrinkle that we have not been able to figure out.Is there any way to run a function before the validation takes place?We have help text displayed in some of our text inputs and text areas,which are cleared onFocus (and restored onBlur if the user has not entered anything). We would like to clear those help text before validation is run, so that we don't get any false validations based on the help text, rather than the actual value of the field, which is blank.
In our application we have used json data and we get json data from the server and on client side we display in grid. We have functionality of paging and filter. so on paging and filtering we process that json data and show to user. For filtering we are comparing each value to the filtered criteria and when json value is more thatn 35 kb it takes around 8-10 second to filter it. So is there any way that we can minimize the processing tiem.
I encountered some code in "Javascript the good part" from Douglas Crockford.There is a way to passing callback function as second argument to string.replace() method.
Code:
var entity = { quot: '"', lt: '<',
[code]....
1. How do I know what the number of parameters should be in callback function ( function(a,b) ) ?
2. How do I know what will be passed in as a and b when I am defining the callback function?
I'm sure this question has been asked many times before, but I can't seem to get the correct terms to find the answer in Google.I understand basic JavaScript inheritance. However, everything I've read makes the inheritance work something like this:
Code JavaScript: var ChildClass = new Function(); ChildClass.prototype = new ParentClass(); ChildClass.constructor = ChildClass;
That's fine, but what happens when ParentClass's constructor needs parameters?As an example, look at the following code:
Code JavaScript: function Furniture(color){ this.color = color;[code)....
How could I "copy" Furniture's constructor into the Chair object? Better yet, how could I copy Furniture's constructor and then add some functionality to it?
jQuery using getJSON calls specific handler, lets say MyHandler.ashx $.getJSON(/MyHandler.ashx?param1=someVal, function(data) { some code; }
In Opera and Explorer this is executed immediately. In FireFox it takes over 1s before request is executed. Even when I set breakpoint in my handler it will be hit after 1s... could you tell me why it is so slow? I got latest version of firefox.
ser is able to create queries and issue them. The query is sent to the web-app by means of an ajax call. Then, the server computes the result set and a small subset (100) of tuples are sent back to the client for visualization.
These thing works with queries that are simple and do not require to the database long computations. As soon as I try a more complex query (computation requires ~ 7secs), the answer returned to the client is empty.
I suspect that this is a problem of timing out the connection, is that possible?
(edit) I have almost forgot, I'm using Prototype as JS library
then I add a sequence of numbers for positioning to an object called pixs (with a numerical index as well that may or may not be useful):
var xpos = startwidth+d_num; var ypos= startheight+d_scroll; pixs[num]= {}; pixs[num]['xpos']=xpos; pixs[num]['ypos']=ypos; pixs[num]['color']=colorval;
As I loop through my arrays of little pieces of data, all of this information is stocked into pixs - BUT then- I have to insert this information from pixs to a function, like:
$(container).fillRect(xpos,ypos, width, height, {color: color}) where width and height are each preset vars.
My challenges here are to 1) successfully loop through the pixs object. 2)Use jquery if possible (or if easier) to get these variable values into the function to evaluate. 3) Successfully '.fillRect' with each loop. 4) Use the append method (or something?! again, I am a n00b) to get all of these instances of fillRect onto the container in the html document (which appears to be set up and working with instances of fillRect not using variables as parameters)
I have a very large tree data structure and I want to display some of its sections on a HTML page. I wrote the following JavaScript that loads parts of the tree dynamically injecting the desired HTML code.
Each show_xxxxxxxx() function displays desired part of the tree on HTML.The problem is each time I load the HTML file it takes a lot of time to read the JavaScript (there are many show_xxxxxxxx() functions with a lot of HTML to insert).Is it possible to cache the loaded JavaScript into browser memory so it won't read the entire script when I reload the page with different content?
My problem is that it takes ages to perform the element.focus() function. This is not a function I have written myself but is part of the Javascript language itself. There are probably a lot of reasons why this might be slow but I cannot find the right one. Let me describe my problem. We have a product which was created around 2004 and has been developed on since. The HTML and Javascript used for the product was based on a prototype which we then converted into a server based solution (we use Servlets/JSP).
Due to the nature of the prototype (and also the graphical layout) the major page consists of one huge HTML page which a lot of hidden DIV tags. These DIV tags are then toggled visible/invisible to make it look like we have a kind of tab functionality. We also do not load all tabs when we load the mail page, instead each tab is loaded into a hidden iframe and then with Javascript we grab the resulting HTML content and paste it into the main page, making that one tab visible while hiding all other tabs.
In one of these tabs we also do some more magic. The layout is as follows; we have sets of three columns each and then a lot of rows. Each set of three columns contains one text field per column. The last text field contains a percentage value and when edited, we check if the value is lower then before the edit and if it is, then we split the column, creating another set of three columns.
When we load the page the first time, there exists only one set of columns with the last column having the value 100. There can however easily be 100 rows as well. For the larger pages we can have (at load time) three columns which makes it 900 text fields. I do not know if this is much or not.So, with the above info, to my problem. First off, when I try to move the marker and click on a given field (so that the marker starts blinking on the selected field) it takes maybe 2-3 second (although not always, seems to be more the first time). If I then tab to the next field it goes very fast (like one would expect).When I try to edit a value (by simply adding or removing values) it again takes a very long time (the first time).
When I then try to tab, it takes ages (this happens always, not only the first time).My Javascript then. I have two events, onchange and onkeydown. onkeydown checks if a variable is set to true or not. If it is set to true, the method does nothing. If set to false it does a bunch of tests and sets the variable to true. onkeydown is what I think causes my first lag but the code is not really that advanced (no loops or anything). onchange does the same checks plus all the magic (with the split etc). One of the last things it does is try to set focus on the next text field and this goes extremely slow all the time.
We use IE8. We (sadly) have a lot of IE specific stuff so the site doesn't even work in Firefox. I have used IE8 Developer Tools and used the Profiler which basically gives a list of Javascript calls and their execution times. My own functions take basically zero time, but there are A LOT of calls to functions that are not named, or anonymous, according to the Profiler.
How do I find what the anonymous function calls are?Why is it the focus() function that takes time, can it (or is it) still some of our own Javascript that makes that function go slow, even though it is part of the Javascript language?Can it be the amount of elements on the page (900 text fields)? Is that much?Can it be IE8? Are there known issues with this?
I'm having a hard time getting my head round it again. I know it could be more efficient in jQuery, but I'd be happy just to get it working, with an extra variable, in straight js.The function takes an array and progressively hides each element at constant interval, in this case 50ms:
function hide_50(arrayA,visibility,current) { if ( current == null ) current = 0; var arrayB=(typeof arrayA == 'string')? arrayA.split(',') : arrayA;
I have a simple calculator here that takes the number of songs from the input text box and multiplies it by 500 and then tells you the total. I am doing this on a simple web page for a project for college. I know document.write overwrites my entire page to print the result but I would like to keep the page and design that I have made and to print the result on the same paragraph as where the script and text box are.
I am new to this discussion but hope you would post reply for my query and encourage me to keep in touch with this discussion. Well here is my problem. I have made an edit in place form in which we can add and remove the elements. I have used jquery.jeditable.mini.js and jquery.duplicate-remove.js plugins for edit in place and add and remove action. I have live() function to access the dynamically ganerated elements like this. $(".addressDiv span").live("mouseover", function(){ clickable function here...
I am trying to understand somecode. I don't think I am understanding everything correctly. Can someone confirm or add to my understanding?
Here is the code, below is my explanation:
- CODE 1 - is saying if the the class subnav_dd is called on an anchor tag on a li, then make the function in the if statement "live". (Live in a sense binds the function to the condition, but unlike bind it allows the condition to be used more then once. ) So if the class subnav_dd is the parent, and has a class of .dis then prevent anything below it from firing. CSS - If code 1 is true, then I will only get the first li to fire, the remaining ones will not.
- CODE 2 - This one is a little tricky. Function ToggleOptions takes 3 variables (target, array, state). The condition is if the div subnav + target have siblings, then check to see how many siblings are there. Put the amount of siblings into an array, then check the state of each sibling. I don't completely the rest of it.
I think if the div subnav is called and something is found in the array then the class dis is either added or removed. Then what? I don't understand why I still need the else that adds a class to #subnav_ +.target
I would like to get a web client's IP where the client is behind a firewall. I googled but hasn't found any solution with javascript that work's. There seems to be a java applet that can do this, but i would like the applet to put it into a "hidden" tag or into a textbox on the HTML page, so when the user clicks "OK" it will be posted to my PHP script.
In my html page i've to show a grid with some data retrieved from an xml file ... i need to this beacuse i've to use online, on a webserver and offline with all files on a usb key, cd, etc ...
which is the best way to accomplish this?
I suppose a solution it could be via javascript:
-locally open the xml file that contains the data e then render then grid. Now i wornder about the best way to do this ... i've read about xsl transofrmation and so on ... if it's possible i'h to achieve this with a cross-browser solution!
Is it possible to add a js function to a loaded web page on the client side? E.g. IE is viewing google, can I add a javascript function to that instance of IE viewing google? I am trying to hook browser events such as button clicks and get information such as edit field text.
I want to create a link that a user can click which will create a popup telling the user their ip address. I have:
var ip = new java.net.InetAddress.getLocalHost().toString(); alert("Your IP address is: " + ip.substring(ip.indexOf("/")+1))
but this does not seem to work. It says the ip is 127.0.0.1. Strangely, this piece of code used to work but all of a sudden it doesn't for some unknown reason. Can anyone tell me what's wrong with the above code?
I want to know about a method for detecting client's IP which is running behind a proxy server. Is there any possible way in Javascript to get the IP address of the client's machine which is using proxy.