javascript

When to separate files to save bandwidth

I'm doing some optimising for my site and am trying to figure out just how big some inline code can be before it can justify having it's own file instead of being written inline. My guess on how to measure it would be that the amount of code (CSS or JS in this case) would need to be bigger than the HTTP packets sent and received to get ...

How do I constrain the size of a tooltip/popup-style DIV so that it doesn't trigger scrollbars on the page

The mouse hovers over an element and a tip appears. The tip overflows the page, triggering a scrollbar, which changes the layout just enough so that the underlying element that triggered the tip is no longer under the mouse pointer, so the tip goes away. The tip goes away, so the scrollbar goes away, and now the mouse is again over th...

Calling As function from js problem

I have a swf file that is not controlled by me. The swf expects a javascript call to set some variables after initialization. The swf is embedded using the swfobject and I'm trying to call the as function right after the embed. This appears to be too soon because I get an error. Everything else should be fine since calling the as funct...

jquery image selector not working in IE7

So I have some html like so: <div id="avatar_choices"> <label for="id_choice_0"> <input id="id_choice_0" type="radio" name="choice" value="7" /> <img src="someimage.jpg" /> </label> <label for="id_choice_1"> <input id="id_choice_1" type="radio" name="choice" value="8" /> <img src="someimage2.jpg" /> <...

Scripting in Java

Me and some friends are writing a MORPG in Java, and we would like to use a scripting language to, eg. to create quests. We have non experience with scripting in Java. We have used Python, but we are very inexperienced with it. One of us also have used Javascript. What scripting language should we use? What scripting language should w...

How can I do automated tests on non JavaScript applications?

I am writing controls that work nice with JavaScript, but they have to work even without it. Now testing with selenium works fine for me. But all test with disabled JavaScript (in my browser) won't run with selenium. Is there a way to do automated test for this purpose? ...

Is it possible to get the position of div within the browser viewport? Not within the document. Within the window.

Is this doable in either IE7 or Firefox? ...

What is the industry and community best practice for coding proper maintainable readable jQuery for a large codebase?

Coming from a Ruby background, I'm used to writing all my code using classes with methods and such. I do know javascript quite well, but I'm new to jQuery and its best practices. Obviously there are a million ways to simulate classes in javascript. But, what is the actual jQuery community REALLY using in the real world? Specific exampl...

Are there any coding standards for JavaScript?

What are the established coding standards for JavaScript? ...

How do I set up gzip compression on a web server?

I have an embedded webserver that has a total of 2 Megs of space on it. Normally you gzip files for the clients benefit, but this would save us space on the server. I read that you can just gzip the js file and save it on the server. I tested that on IIS and I didn't have any luck at all. What exactly do I need to do on every step of...

JavaScript - How do I learn about "closures" usage?

From Wikipedia, the free encyclopedia: Closure (computer science) In computer science, a closure is a function that is evaluated in an environment containing one or more bound variables. When called, the function can access these variables. The explicit use of closures is associated with functional programming and with ...

a script on this page is causing ie to run slowly

The problem is in the title - IE is misbehaving and is saying that there is a script running slowly - FF and Chrome don't have this problem. How can I find the problem . .there's a lot of JS on that page. Checking by hand is not a good ideea EDIT : It's a page from a project i'm working on... but I need a tool to find the problem. End...

Drop Down List Issue

Hi all, I’m having an issue where a drop down list in IE 6/7 is behaving as such: You can see that the drop down width is not wide enough to display the whole text without expanding the overall drop down list. However in Firefox, there is no issue as it expands the width accordingly. This is the behaviour we want in IE 6/7: We’ve...

ListBox elements rearranged with JavaScript causing event validation error on postback

I have created an item swapper control consisting in two listboxes and some buttons that allow me to swap items between the two lists. The swapping is done using javascript. I also move items up and down in the list. Basically when I move the items to the list box on the right I store the datakeys of the elements (GUIDs) in a hiddenfiel...

window.ScrollMaxY or X - How to set in FireFox 3?

window.scrollMaxY can be set via that property in IE and older versions of Firefox, but when trying in FF3 it says "Cannot set this property as it only has a getter". What is my alternative? EDIT: The reason why I'm asking is that I'm fixing some very horrible JS written by someone else, it has a function to keep a div centered on the...

What is the maximum length allowed for window.returnValue property? (JavaScript)

Is there a maximum length when using window.returnValue (variant) in a modal? I am calling a modal window using showModalDialog() and returning a comma delimited string. After selecting a group of users, I am putting them into a stringbuilder to display in a literal. Dim strReturn As New StringBuilder strReturn.Append("<script type=...

Separating client side logic from server side logic in a reusable way using MVC

Before you answer, this question is complicated: We are developing in asp.net / asp.net mvc / jQuery but I'm open to solutions on any platform using any framework I think logic like sorting / hiding columns / re-arranging columns / validation (where it makes sense) should be on the client-side I think logic like searching / updating th...

Multiple rows with jcarousel

I'm trying to use jcarousel to build a container with multiple rows, I've tried a few things but have had no luck. Can anyone make any suggestions on how to create it? ...

Javascript Removing Whitespace When It Shouldn't?

I have a HTML file that has code similar to the following. <table> <tr> <td id="MyCell">Hello World</td> </tr> </table> I am using javascript like the following to get the value document.getElementById(cell2.Element.id).innerText This returns the text "Hello World" with only 1 space between hello and world. I MUST kee...

Javascript Postback in Grails

Does anyone know how to initiate a POST request in a Grails applications using javascript. Specifically, I would like to be able to POST when a the selected item in a drop-down box is changed. I've tried using jQuery and the $.post() method. It successfully calls my controller action, but I'm not sure how to get the page to refresh wit...