javascript

Beginner JavaScript: Working with JSON and Objects in JavaScript

I have some JSON returned to the browser like this "product": { "Title": "School Bag", "Image": "/images/school-bag.jpg" } I want this data to be a "Product" object so I can use prototype methods like a toHTMLImage() that returns a HTML image representation of the product: function Product() { } Product.prototype.toHTMLImage = functi...

Get/Set caret position of iFrame in Safari & Chrome

I'm using the jQuery plugin lwrte (http://code.google.com/p/lwrte/). I've implemented a custom drop down in the panel of the wysiwyg that, when select, outputs a value at the cursor position. This jQuery plugin uses an iFrame to accomplish the wysiwyg functionality. The above works in IE and in FF, but is broken in Chrome and Safari. Th...

How to cancel navigation when user clicks a link?

I'm trying to load some stuff using AJAX when a user clicks a link, but I want the link to actually go somewhere so that the app still works when javascript is disabled. Is there any way to just do something with javascript and cancel navigation when a link is clicked? What's the best practice? Can that be done, or do I need to replace ...

How to force IE to reload javascript?

I'm using IE 8 on Vista, and everytime I change a javascript file and then start debugging, I have to hit Ctrl+F5 to have it reload my javascript. Is there any way to make it automatically reload javascript when I start debugging, but not lose the performance gains when just browsing the net? Yeah yeah I know you probably don't like IE,...

JSON viewer for Linux

Can anyone recommend a good JSON viewer (or even editor) for Linux? ...

ASP.NET CheckBox disabling postback with javascript

I'm trying to wire up a CheckBox to handle an event when check/unchecked. If the user has JavaScript enabled, use that, otherwise use a postback. Here is my code: <asp:CheckBox ID="ApplicationInProcessCheckBox" runat="server" Text="Application In Process" AutoPostBack="true" oncheckedchanged="ApplicationInProcessCheckBox_Che...

Javascript image change causes embeded UserControls to flicker

I have a n html page being displayed in IE. It has some buttons made up of images with mouseover/mouseout events on them in JavaScript, and a bunch of embedded .Net UserControls. When the mouseover/mouseout events fire, I change the images src to something else (simple rollover effect). The problem is that the UserControls often (but ...

Using javascript to loop dynamically created controls with php

Ok, this situation is a little weird but anyway. This PHP code generates several radiobuttons: for($i = 0; $i<count($questionList); $i++) { echo $questionList[$i]->__get(QuestionId).'-'.$questionList[$i]->__get(QuestionText).'<br />'; $answerList = $questionList[$i]->GetAnswers(); for($j = 0; $j<count($answerLis...

How to Fix Browser Compatibility

I have developed a html file. It is working fine in IE6 and IE7. When I run the same html file in IE8, the design is not the same and the Javascript is not working properly. It is showing browser's "Compatibility view"? How do I fix this? ...

jquery form validation with two validation messages.

Client side form validation becomes easiest by using jQuery. I tried all validators and they are so simple! But in date, number and range validators; I need to add two validators in sequence 1) Required 2) Date so is it possible. Another common requirement is to reset the Form Fiels. Is is possible using jQuery without writing too ...

Can we do fade in and fade out in iframes

Hi everyone, Is it possible to make fade in and fade out transitions in iframes? Thanks & Regards Ravi ...

Deallocating memory used by Javascript objects

Should I free the allocated memory by myself, or is there a kind of garbage collector? Is it ok to use th following code in javascript? function fillArray() { var c = new Array; c.push(3); c.push(2); return c; } var arr = fillArray(); var d = arr.pop() thanks ...

Regular Expression to Detect and Update String ( Useful to Update File Version in AssemblyInfo.cs)

I have a string of this format 1.0.x.0 I have to write a regex in javascript that automatically increment the x-- How to do it? Note, the string given will always be of that format-- no need to test for format validity... ...

How to make options for popup window..eg size

I have the following function to make a popup window. function makewindows(html){ child1 = window.open ("about:blank"); child1.document.write(html); child1.document.close(); } It works fine, but it opens a new tab in firefox. I would like to know how to make it an actual popup, with a smaller size and such, separate from the actual w...

How to load a js file with javascript

I want to get over a nasty problem that shows up yesterday during a demo to a client. We're using jquery, loading it from google api. But yesterday, our ISP begin to cause some problems, and didn't load jq.js properly. So, what I really want is to load a local file from the server if google api has an extrange behaviour (not that it's ...

Working with javascript in VIsual Studio

To work with JS files in Visual Studio 2008, I did: Tools -> Options -> Text Editor -> File Extensions and added js extension with Script editing experience. That works pretty much as expected apart from the following things: Syntax highlighting is set-up extremely slow (after 10 seconds or so) when I open the JS file. The compilin...

Hide an element's next sibling with Javascript

I have an element grabbed from document.getElementById('the_id'). How can I get its next sibling and hide it? I tried this but it didn't work: elem.nextSibling.style.display = 'none'; Firebug error was elem.nextSibling.style is undefined. ...

Problems with mixing form and mysql database query

I have the following form, which I have reduced as much as I can, without being sure where the problem is coming from. I am trying to insert the form values into a database. However, when trying to use the form below, it spits out: Query was empty twice. The STATUS table exists, as do the fields deleted and notice. The table is curren...

Progress/busy indicator while waiting for file download in javascript?

Hi all, here is the situation: In the web application, user selects some options, submits form, and PDF file is dynamically generated on the server side and offered for download. The problem: The generation of PDF file takes quite long (up to 1 minute). Some users think nothing is hapening and keep clicking the submit button again and ...

Combining and Compressing multiple JavaScript files in php

Hello, I am working on a PHP app that requires eight javascript files (hello web2.0). I am wondering what the best way combine and compress all of the files dynamically. Am I phrasing the question correctly? The end result is that I would include one .js file in the header, and that .js file would include of the .js files in my "incl...