javascript

jQuery: "this.cloneNode is not a function" when included on a page with Prototype

Hi All, I'm trying to use jQuery in a bookmarklet, which means I don't have control of the page into which the JavaScript will be inserted. From what I've read of noConflict, it requires that jQuery be inserted first. In the case of a bookmarklet, just the opposite is true. So - does anyone have any suggestions on whether or not this...

Image with rollovers

Hi, I have a big image that has to go in the background. Say the image is a square. Now when someone does a mouseover on any of the square's corners, the image should change to the green version of the image. Actually the background image is going to remain, but I have to somehow overlay the green image slice over the background im...

Disable HTML element in the client side (javascript)

I am looking for the simplest way to disable a whole HTML element (typically a <div>). With "disable" I mean a way to prevent the user to click on any of the elements contained into the element. For instance, if you have a form into the disabled element, the form elements won't catch the focus. I've tried with a method that traverses t...

How do you create a method for a custom object in JavaScript?

Is it like... var obj = new Object(); obj.function1 = function(){ //code } or something like that? ...

How can you measure the space that a text will take in Javascript?

In Javascript, I have a certain string, and I would like to somehow measure how much space (in pixels) it will take within a certain element. Basically what I have is an element that will float above everything else (like a tooltip), and I need to set its width manually through Javascript, so it will adjust to the text inside. I can't h...

Setting focus in ASP

I’m maintaining a site in ASP, one of the tasks is to set the focus on textbox on a page. Here is what I have tried: <script type="text/javascript"> <!-- document.psForm['password'].focus(); //AND document.getElementById("password").focus(); --> </script> I didn't think this would work... and it doesn't: <form id="psForm" action="lo...

finding object in Javascript

I have a form with thousands of checkboxes, and when one is checked, I want to check all the boxes below it. This works: <html> <body> <form name="myform"> <input type="checkbox" name="box1" onClick="redrawboxes(this);">1<br> <input type="checkbox" name="box2" onClick="redrawboxes(this);">2<br> ... </form> </body> </html> <script> funct...

Text Editor with Scripting...for Linux

For a while now, I have been using UltraEdit on my Windows box. The ability to write scripts with a familiar language (JavaScript) has proved to be extremely useful. The only problem is that I cannot use it on my Linux box at work. Is there a comparable text editor that runs on Linux and has an integrated scripting engine? Not breaki...

will Array.sort() preserve the order of the array, where possible?

I suppose it depends on how it's implemented. I'd love it if someone would come back and tell me "yes, in virtually all browsers, order of items will be changed only when necessary to satisfy the conditions of the sort. ...

Accessing properties of window with Selenium

The page I am trying to test sets the value of "global variables". From the Firebug, I can access those as properties of the window object (e.g. window.foo). From Selenium however, typeof selenium.browserbot.getCurrentWindow().foo always return "undefined", say when used in the condition of a waitForCondition. Any idea of what I could b...

Refresh A Image Src...

k... Strager was able to help me a bit. However, it's still not working quite right. Need someone that knows both MVC and jQuery please... I have a page that has a image that when clicked on will launch a dialog box that gives the ability to upload a file. Once the dialog closes the image is supposed to refresh with what was uploaded/st...

Validate specific input, Javascript

<form action="/cgi-bin/Lib.exe" method=POST name="checks"> <input type=checkbox name="user1" value="'$NAME'"> <input type=checkbox name="user2" value="'$NAME'"> <input type=checkbox name="user3" value="'$NAME'"> <input type="button" value="User 1" onclick="somefunction()"> For example, if I selected c...

What good is JSLint if jQuery fails the validation

So I have been exploring different methods to clean up and test my JavaScript. I figured just like any other language one way to get better is to read good code. jQuery is very popular so it must have a certain degree of good coding. So why when I run jQuery through JSLint's validation it gives me this message: Error: Problem ...

How do I combine WebResource.axd and ScriptResource.axd files so as to result in less requests to my ASP.NET server?

On a site I'm working on, the pages are generating 45 external WebResource.axd and ScriptResource.axd files so the broswers have to request all 45 references. That's a lot of references so I'd like to know if there is a way that all of those requests could be combined into one request? I've seen that the Script Manager is supposed to be ...

JSON is used only for JavaScript?

I am storing a JSON string in the database that represents a set of properties. In the code behind, I export it and use it for some custom logic. Essentially, I am using it only as a storage mechanism. I understand XML is better suited for this but I read that JSON is faster and preferred. Is it a good practice to use JSON if the intent...

How, using JavaScript, do I change an <a> tag's onclick event handler to a function with parameters?

I'm aware that you can set an onclick handler like this: my_a = document.createElement('a'); my_a.onclick = somefunction; ... but what if somefunction takes a parameter? For the sake of simplicity, let's say I need to pass it the string "x". Is is possible to dynamically set the onclick handler to somefunction('x')? ...

Idiomatic way to set default value in javascript

What would be the most idiomatic way to do the following in javascript: If myParam is not passed into MyFunc by the caller, then I want to set it to a default value. But first I want to try and get it from another object, which may not yet exist: function MyFunc(myParam) { if (!myParam) { if (!myObj) { myPara...

Delay text from displaying and fading in the background-color

I want to fade in text when loading a page, w/ the background-color slowly fading in as well. <div id="alert-box"> <p>This is the alert box, this message will display 5 seconds after page is loaded, with the background-color fading in.</p> </div> Here is what I have for the jQuery for now: $(document.body).click(function () { $...

delaying the loading of a certain css background image

in a CSS like this : ... #big-menu { background: #fff url(../images/big-menu.jpg) no-repeat; } #some-menu { background: #fff url(../images/some-menu.jpg) no-repeat; } #some-other-menu { background: #fff url(../images/some-other-menu.jpg) no-repeat; } ... is there a way to delay the loading of #big-menu's background image, ...

javascript 64 bit numeric precision

Hi, Is there a way to represent a number with higher than 53 digit precision in javascript? In other words, is there a way to represent 64 bit precision number? I am trying to implement a logic in which each bit of a 64bit number represents something. I loose the lower significant bits when I try to set bits higher than 2^53. Math.pow(...