javascript

Famous javascript libraries.

What are the most famous JavaScript libraries? ...

Why is accessing dimensions of the image so expensive in JavaScript on IE8?

I have to process loads of images. First, I need to check if the size of the image is greater than 50x60 and appropriately increasing the counter of bad images. The problem I have is that the speed of n.width / n.height on Internet Explorer 8 is extremely low. I checked n.offsetWidth, n.clientWidth but they are all the same speed-wise. ...

Should I use HTML comments to capsulate JavaScript code blocks?

Some years ago, I was taught that JavaScript code blocks embedded inside HTML should always be capsulated inside HTML comments as following: <script type="text/javascript"> <!-- /* JavaScript code comes here */ --> </script> I was told to do this, but I never kind of fully figured out why. It kind of seems hacky to use HTML comments, ...

How to change a model property from a javascript function inside a view?

Hello, Is there any way to alter my Model properties from a javascript function inside a view? Specifically, I have an edit view and need to access a string property value with function SomeJSFunction() { var somevar = '<%=Model.Property %>'; ... then do some changes on somevar and set the model property to the changed s...

javascript object literal pattern with multiple instances

I have developed a little javscript widget to turn some nested <ul> blocks into a windows explorer style browser. I have recently learnt about the object literal pattern and decided to give it a go, so the organisation of my code is something like this: var myExplorer = { init : function(settings) { myExplorer.config = { ...

Find the height of dynamically created div

Hi All, Neither of the properties clientHeight and offsetHeight has worked out for me while I try to determine the height of the div created dynamically. Could someone suggest alternative please? Thanks a ton in advance. ...

Jquery selector not working when element contains dot in tag name

Hi All, I have just started using jquery for the first time so i'm not sure if what i'm doing is correct. What i'm trying to do is very basic, I have a script which is adding a css watermark to textboxes upon load in an MVC view. To select the element i do the following: jQuery(document).ready(function(){$('#Department.DeptName').a...

Formatting a date for output

How I can format a date string using Javascript. For example: var date_str = "2010-10-06T03:39:41+0000"; The result should be like this: 11:39 AM Oct 6th Is there any ideas on this? Note: date_str is an example of returned date from Facebook Graph API. Thanks in advance. ...

iframe dynamic height width change based on inner content

Hi, I have iframe with content like below, <iframe frameborder="no" src="http:localhost/com" id="iframe"> <div style="height:850px;width:700px;">div text </div> </iframe> This shows the iframe with hori. and vertical scroll but not the height on inner content of 850px. how can i change the iframe height dynamiclly base...

Array exists in an array of arrays

How can I check if an array exists in an array of arrays ? I have tried either plain javascript and jquery methods but none seems to help. IE this doesn't work: $.inArray( [1,2], [[0], [], [1,2]] ) Even a more simple one: [1,2] == [1,2] //gives false. [1,2] === [1,2] //gives false. ORDER is NOT important for my task, only same ele...

fire zoom in event in firefox with javascript

Hello, i'm trying to fire the zoom in event from firefox with javascript. But i can't access to this firefox function. I would like to do the same thing when you press view -> zoom -> zoom in. So that pictures and text will enlarge. Is there any possibility? I'm using Firefox 3.6.10. Thank you all in advance. ...

Open source browser based (i.e. javascript) highlighter for Python code?

I have an html page with a textarea in which users type python code. I'd like for the input python code to be highlighted as they type, much as a desktop-based IDE would do. Unlike this question, I don't want the code to be passed to the server and returned highlighted - I'd like for it all to be done by javascript in the browser. Rat...

HTML formatter/tidy/beautifier for JavaScript

Is there any HTML formatter/tidy/beautifier out there written in JavaScript? I have made a content editor (CMS) which has both WYSIWYG and source code views. The problem the code written by the WYSIWYG editor is normally a single line. So I would like a JavaScript that could format this into a more readable form on demand. ...

What does fn mean when used in Raphael?

I saw a fn use in raphael, which is a javascript lab. Raphael.fn.g.piechart = function (cx, cy, r, values, opts) { // blah...blah } it extend raphael, so people can uses like r = Raphael; r.g.piechart. I search google and have nothing seem to be clear my mind. hope you help. ...

How to get the object which fired the event in jquery?

In javascript, we have event.srcElement that gives us the element on which some event is occured. Is there any way by which we can get this object in jQuery. Also, function myFun(){ alert ( $(this) ); // what do this object represent? Is it what i need ? } ...

jQuery 'event not defined' error on simulated key press

Hi, I am currently trying to use jquery to enter a selection from a dropdown into a text box, simulate a click to select it, press return, wait for some processing and then press return again. It's quite a nasty way of getting what I need but it's the only way I can see at the moment. Here is the code: $('#fav').change(function() {...

Javascript event propagation with image map

Hi, I'm making an image map of the world map where moving the mouse over different parts of the world should highlight that part of the world. I do this by loading images of the different regions into an (initially) empty 'div' and positioning them on top of the world map with css and absolute positioning. It works well except that th...

Date comparison in Jquery

Hi.. I want to compare the selected date and current date. Iam using jquery date picker. While using the following code only the date field comparison is takes place... How can i compare with month and year also... Advance thanks.. $(document).ready(function() { var objDate = new Date(); var selectedDate = document.getE...

How to define a new global object in javascript

Hi It is good practice to create one unique global object that wrap the functions and properties inside this object.I look up a lot of sample code and see code like this if(!myglobalObject) myglobalObject ={}; However , this code does not work ,I got an error saying ReferenceError: myglobalObject is not defined Can anyone shed some l...

how to replace \ with \\ using javascript string functions

I have the following filepath var imagepath="C:\Documents and Settings\Mahesh\Desktop\images\advts.png" how can i replace \ with \ so so that it prints var imagepath="C:\\Documents and Settings\\Mahesh\\Desktop\\images\\advts.png" ...