javascript

Where should I put my JavaScript - page or external file?

In VS 2008, I have an ASP.NET content page having one master page. I would like to add JavaScript functions for client side validation etc. for this page. My questions are: Should I write these scripts in a separate .js file, or embedded within the .aspx file. Does this choice affect the performance of the website? Are there any rules...

Dashcode List - OnClick

I have created a project in Dashcode, inserted a List control, enabled a dynamic list, created a JSON object and associated it with the control. The code looks like this ... var stations = { _rowData: ["Mitchelton", "Gaythorne", "Albion", "Central", "Burpengary", "Petrie", "Morayfield", "Caboolture", "Ferny Grove"], numbe...

Javascript - Change font color of certain text in textarea

Is there any JS function that can change the color of certain text in a textarea? For example, blar blar {blar} blar, {blar}, including { }, will be in blue. Other words will be in blank. In other words, all I need is a function that can change color of all text in { }. I've done some studies and it seems that most people say it can't ...

MVP pattern with Javascript framework?

Has anyone been able to implement the MVP model with any javascript frameworks? I'm having trouble figuring out how to have the presenter -> view inversion from server code to javascript. I have some ideas, but kind of hackish and would like to see what others are doing. ...

jquery- jeditable not working

basically what I want is simple, when people onclick, the field become editable. After they change the value, press Esc at keyboard/ or click outside , to save the record. I'm not sure why it's not working. Documentation seems not complete... Anyone got idea on how this work? The documentation page: http://www.appelsiini.net/projects/...

Javascript prototype inheritance difference

function main() { this.one = 1; } main.prototype = { display: function() { console.log(this.one); return this; } }; function addition() { main.call(this); } addition.prototype = new main; addition.prototype.constructor = addition; addition.prototype = { add: function(x) { this.one += x; return this; } }...

How to prevent the user to change page with jQuery

I have a page with a form that is submittes via ajaxSubmit() (so, without changing the page). My goal is that, when the user try to change page (or even to close the browser), i ask him if really want to exit the page without sending the form (exactly as gmail does). Gmail for example do this with a window.confirm-like popup, but if it...

Javascript Object Literal and Array Problem

I have the following javascript: oCoord = { x: null, y: null }; var aStack = []; oCoord.x = 726; oCoord.y = 52; aStack.push( oCoord ); oCoord.x = 76; oCoord.y = 532; aStack.push( oCoord ); oCoord.x = 716; oCoord.y = 529; aStack.push( oCoord ); Now this creates the following structure (an array of 3 objects) Array[ Obje...

jquery dynamic pagination for comments

I would like to create a pagination system for comments in my website.So far, I have been able to create pagination using php/mysql and html but the page has to refresh every time we click on the next button(for the next set of comments) or previous or a particular page.... As far as my knowledge of jquery is concerned I am thinking th...

Javascript PHPBB-like URL tag processing

Hi all! I'm working on a php dynamic web page that has a element that let user write and their text is show in "real time" just javascript-processing the text & tags on a element. I change the "b","u", and tags between brackets (like phpbb style) to its html equivalent like "strong" ,"u", and so using javascript regexps. Problem occ...

Using jQuery.data to store a list of items

I'm working on a page where I need to associate a list of objects with a row of a table, and I'm using jQuery. jQuery.data seems to just associate a piece of data with a key, whereas I need more like id=4,setting=2 id=3,setting=1 ... I don't know how long the list could be, and it could be empty. Is there a sensible way of doing thi...

Default text on input

How to set blank default text on input field and clear it when element is active. ...

Slow animation with webkit-transform translate() in iPhone OS 3.0

Has something changed in JavaScript handling in iPhone OS 3.0? This code works in Safari 4 Public Beta and in iPod Touch 2.0, but not in iPod touch with iPhone OS 3.0. The purpose is to move the box a little to the right in 2 seconds, but in 3.0 it just jumps to the new location without animation or delay. <html> <head> <meta name="view...

The way to check the javascript injections

Is it enough to avoid javascript injection validating input data in such way: xssValidate = function(value) { var container = $("<u></u>").text(value); if($(container).html() != value) return mc.ERROR_INVALID_FORMAT; } I've managed to validate all the text fields and textareas values with the code above before submit them to s...

Expanding a hidden div by referring with an anchor from external page

I have a script which hides (display:none) certain divs in the list on page load. Div contents represents description of a book, and the whole list is some sort of bibliography. Every div has an id, for example, "div1", "div2" etc. <ul> <li><div class="hidden" id="div1"></li> <li><div class="hidden" id="div1"></li> ... </ul> ...

changing class of a <span> element with JavaScript

I am trying to change the class of a element with Javascript using the below code: parent.document.getElementById('<?php echo $markid ?>').class = 'unlistened'; Not having much luck though. How do I do this properly? ...

JavaScript: should i use ' or " char to define string?

Possible Duplicate: What is the difference between and in JavaScript? Should i use ' or " char, to define a string in javascript? Is it just a developer's choice? I think, strings more offten contains ' char, so i prefer using of "(with inner " translated to \"). What do you think? ...

Using Javascript OnChange Event to Conditionally Cancel AutoPostBack on Textbox

I'm having trouble figuring out a way to conditionally cancel an asp:TextBox's OnTextChanged AutoPostBack using a javascript onchange event. I want to do this because it would be easy for me to check some conditions on the client side that would negate the necessity of doing a post-back. I have something like this generated in the cli...

Problem setting equal heights with jQuery in IE

I have several of the same class of element on a page and am attempting to get them all to be the same height even though the content within varies slightly. I've put together a small function that yields results in both Firefox 2+ and Safari 3+ but apparently doesn't even register in IE 7. Here's what I'm using: var tallestcopy = 0; ...

Why doesn't function.apply() work across document boundaries in IE?

I'm seeing some strange behavior in IE trying to call functions in another page via function.apply(). Here's a simple test case: test1.html: <HTML> <HEAD> <script language="javascript" type="text/javascript"> var opened = null; function applyNone() { opened.testFunc.apply(opened); } function applyArgs() { opened.test...