javascript

JS λ-functions & "upper context" variables

Say I have some context where variables are set and a λ-function is called which uses them directly: function outerContext(){ ... var data = ...; // some data the script uses ... someObject.method = function(){ data; // the variable is used here }; ... } I know that the dynamically created funct...

Remove style from selected span/text in div

Consider this snippet: <div> <span style="color:red;">a</span> <span style="color:blue;">a</span> <span style="color:white;">a</span> </div> How can you remove style from selected by user text? Edited: to add clarifications from OP: Thank you for your answers! I had to be more precise. Sorry for that. What do I mean...

Javascript: How to Keep Persistant Array Data

Hi, I'm trying to build an array in javascript that contains a list of ids. Here is a simplified version of the function that I have... function updateCost(id) { var inputArray = []; inputArray.push(id); } And here is the html code... <input type="file" name="field1" id="field1" onchange="updateCost('1');" /> <input type="f...

How to Prevent Page Change when using Firebug

I want to inspect the request that will change window.location or whatever it may be using to change the url. I don't know where in the code it is changing the url so I can't put a breakpoint in there. How can I use Firebug to allow Ajax requests but prevent the url from changing? Or how can I otherwise inspect the request that will c...

Can you get a list of Firefox add-ons programmtically

I spent a fair amount of time trying to determine why my view of a site didn't match a clients, after looking at the cache etc. we determined the problem to be with one of the add-ons (Adblock Plus in this particular case). It would have been much simpler if we could have had an easy way to query what add-ons were installed, and ideally ...

Looking for a better workaround to Chrome select on focus bug

I have the same problem as the user in this question, which is due to this bug in Webkit. However, the workaround provided will not work for my app. Let me re-state the problem so that you don't have to go read another question: I am trying to select all the text in a textarea when it gets focus. The following jQuery code works in IE/FF...

auto-resize images in posts with link to image URL?

This will be used in my community website (forum, articles) where some users post very large image. I can auto-resize the images using below codes #post img { max-height: 1000px; max-width: 700px; } But one more, I want (on every resized image) a link created to that image URL. So when visitor click the link, they can see the...

Not able to track enter key on input type = text

Can anybody tell me why is this not working? <input name ="txtChat" id ="txtChat" onkeydown ="isEnterPressed();" type="text" style="width:720px;"/> This is my javascript function :- function isEnterPressed(event){ alert(event); } On alert i always gets undefined :( Thanks in advance :) ...

Why does graphics have ugly black borders in IE after alpha animation?

The site I'm working on opens with a fancy jQuery opacity animation. Currently It's working in all browsers, but in IE all text and alpha images are left with ugly black borders that makes the text practically unreadable. Is there some clever javascript command i can run to refresh/update the graphics? Any other way to fix this? My pro...

HTML5 Web SQL Database for non compatible browser?

I really like sql-database in HTML5, but so far only Opera and Webkit browsers support this feature. Are there any javascript libraries out there that replicate this feature or provide something close to this? Thanks! ...

Reading JSON arrays with jQuery/JS

Alright, this pretty much goes along with my previous question. I'm still trying to figure out how to display data from an array which is created by a PHP file- using JS/jQuery. I'm working on a points system for ZetaBoards, and I've currently got it set up here. (Points will be displayed below the users post count once I get this workin...

IE getelementbyid for object in the document

Hi there I do not whether I should ask be asking this question. I need to getElementbyid for an object which is already exisiting in the document. In the example, I would like to get the element "test" which is sub of parentDiv1. Could anyone help? It is ok with ff but not with IE. Any tips? Example: <div id="parentDiv1"> <ul id=...

Jquery to stylize only certain word from para...

Hello, I want to stylize only certain word from my dynamic div say, <div id="info">{$info}</div> prints <p>here you can get info about somnething. if you want more info about something then click here....</p> I only want stylize the word 'info' How can I achieve this using jQuery? Thanks. ...

How can javascript work perfectly in FireFox, but not work at all in other browsers?

I use FireFox as my main browser, especially when testing out my site, Avoru. However, when checking to see if my code was working properly across other major browsers (Google Chrome, Opera, and Safari), I found that none of my custom javascript seemed to work. Although the functions and code were clear in the page source, using typeof r...

Selecting readOnly textboxes with JQuery

Hi, In my ASP.NET MVC project i need to select all text boxes that have attributed "readOnly" in current page and show modal Jquery dialog in keypress on the disabled text box.Any help appreciated. ...

Cannot drag selection in Jcrop, what could break it?

I'm at a loss. I'm using JQuery 1.4.2 and JCrop 0.98. Everything else works fine, but I cannot move a selection once created. When I mouse over the selection and click, nothing happens. I have the JQuery library, the JCrop library and the JCrop css file all included. It's a pretty clean page without much else on it. I don't know if...

stop jquery live from hooking all the children.

I can't stop the stupid thing from firing off an event when hovering over the children of item. I only want the event to fire via the div.item element, not the div.itemChild. This is driving me nuts please help. event.stopPropigation does not work. nor does if(!$(event.source).is('itemChild')), for some reason is() alway returns false. ...

How do I write a function as both an event handler and a callable function that takes an argument?

Here's a function for use as an event handler that makes use of this: function validate() { if (this.val() == '') { return false; } } $(':input').change(validate); Here's the same function rewritten to take an argument, so that I can call it explicitly: function validate(field) { if ($(field).val() == '') { return fals...

In how many ways a website can be accessed and should we consider all condition?

As far as i know a website can be accessed on Desktop Browser Text only browser Mobile phone browser PSP Iphone/ipad touch screen and conditions JavaScript disabled CSS disabled JavaScript and CSS both disabled images disabled with screen reader and keyboard with keyboard only with keyboard and mouse combination. Color Monitor B&W ...

I can't get live() to act like hover()

I'm having a really big problem with live binding in jQuery 1.4. I want to bind a hover event to the div.message elements and fade in the controls. They are hidden by default. This is easy when using .hover(), but doesn't bind new items that are added via ajax. I've tried .live() with no success. It fires the mouseover and mouseout event...