javascript

What are the disadvantages of using backend generated Javascript or CSS?

Just curious. My thought is that generated files have negligible overhead in terms of performance but I could be mistaken. Any thoughts on this? ...

Jquery to merge all referenced pages into root page?

This sounds a little obscure, but... Is there a technique in Jquery (or just straight javascript) to step thru all the external CSS and JS file references in an HTML file and replace the references with the contents of the files. So instead of: <link rel='stylesheet' id='style-css' href='http://domain.com/style.css' type='text/css' me...

Create an image of a div?

Hi all, I was wondering if it's possible to create an image of a div inside a page in php, jquery or javascript? Or even just a screenshot of the entire page (on my own server - not external).. What I want to do is create an image of a graph (drawn in via jQuery) and pass it onto a PDF, as I can't seem to get the jQuery to display in th...

Comparations of Objects

Hi guys. A object in Javascript have a lot of properties and got this code: var div = document.getElementsByTagName ("div"); if (div[2] === div[2]) { alert ("..."); } There is no "id", "class", "name" or "value", so how can "div[2] === div[2]" works ? What property of the object JavaSc...

form validation with javascript vs php

Why should I bother to use JavaScript for form validation when I still have to use PHP since the user could have JavaScript support turned off. Isn't it unnecessary? Update: Ok thanks for your answers. it sounds like a good idea to have it on the client side too. where can I download good JavaScript validations? Do you know where I c...

JavaScript: Rounding to two decimal places. Not less than two

Hello all, I have this line of code which rounds my numbers to 2 decimal places. But the thing is I get numbers like this. 10.8, 2.4 etc. These are not my idea of 2 decimal places so how I can improve this: Math.round(price*Math.pow(10,2))/Math.pow(10,2); I want numbers like 10.80, 2.40 etc. Use of JQuery is fine with me. Thanks for...

msie strange div formatting (among other issues) what am I doing wrong?

Hi folks. On the page http://listtree.appspot.com/about/bEcPYABxI$6UeBDHzASwlA if I scroll to the bottom using MSIE 8 the left hand side yellow div borders to a weird jumping up and down dance -- what am I doing wrong? I have similar pages where this isn't happening and the "developers tools" interface seems happy with the html. Also...

Javascript "do-while" type loop

I'm working with some JS code that I inherited on a project, and in several instances it has loops set up like this one: while(text = someBufferObject.read()) { //do stuff with text } I'm assuming this is to achieve some sort of do-while type functionality. However, when I run this through JSLINT it complains that it "Expected a con...

How to close my popupwindow once the submit button click??

hi. i create a popupwindow which open 1 of my pages from my cakephp. This popup is a form which link to other page. Upon u click the 'Submit' button, it wil auto save the data to Mysql and close it. I would like to close the popup window once the click submit button. i set top.close(); but stil no function. What i mising.. <script t...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript and put it before the end of body tag, because this script uses the google analytics variables. How can i achieve this? ...

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet Explorer Thanks ...

selected text in iframe

How to get a selected text inside a iframe. I my page i'm having a iframe which is editable true. So how can i get the selected text in that iframe. ...

Should I learn the Google Closure JavaScript framework, or is it just a passing (albeit Google branded) framework?

By now, I'm sure a lot of people will agree jQuery is pretty much the standard JavaScript framework (or as much as one can ever be). I mean, it has been adopted by Nokia and Microsoft. Now that Google has put out it's own framework, is it worth my time learning it? Do you expect good adoption of it because of the Google name? ...

Replacing text only within the within the specified node, and not within child nodes.

I found a GreaseMonkey script on Userscripts which corrects spelling and some grammar which I'm trying to improve for use on Reddit etc. I've had some help from there improving it, and this is my current version which does work quite well. There is, however, a problem in that it capitalises italics, bold and links. I would like to have...

JavaScript syntax checking and compression

Do you know a good syntax checker and compressor for JavaScript? We are currently using JSLINT as syntax checker and YUI for compression. Note we are using the library ExtJS for UI. ...

How to loop though a jQuery result set

I'm trying to learn jquery and I'm having some difficulty figuring out how to deal with a set of jquery results. Let's say I have some html like: <div class="divClass"> <p class="pClass1">1</p> <p class="pClass2">Some text.</p> </div> <div class="divClass"> <p class="pClass1">2</p> <p class="pClass2">Some text.</p> </div> <div c...

Starting out with rails. Suggestions for SDKs plug-ins etc?

I have 6 years of C# programming experience and I'm looking to broaden my horizons. I'm going to build a simple web app to demonstrate knowledge of Ruby on Rails so I can get my foot in a place that might want a Rails programmer. It's the hot new thing, so I want to be marketable. Anyway, I have been playing around with solr and tomcat ...

How to implement a slide-out/drawer effect in JQuery?

I'm looking for a JQuery plug-in for a drawer-like effect. I found that plug-in which is quite similar to what I want but it slides from one side of the screen (top, bottom, left or right). In my case, I have an image as wide as the content div, and I want it to slide down when clicked to reveal the content, but not from the top of the s...

javascript and regularexpression?

hi, i have a doubt that whether javascript expression is better or regularexpression is better. i mean for validation javascript is best or ?How it is different form each other? thank you. ...

how to detect when a shortcut key is pressed in javascript

How can i detect a shortcut key, [ in my case [ ctrl + shift + k ] ] in javascript? Like, i have to show a dialog if user presses this key. ...