javascript

JavaScript: Get local variable dynamicly by name string

<script> //in one script var someVarName_10 = 20; </script> I want to get access to this variable from another script by name of variable. With window object its simple, is it possible with local variable? I mean access this var by code like this: <script> alert(all_vars['someVar' + 'Name' + num]); </script> ...

JavaScript: Find out if function is anonymous or is defined in a object

I'm trying to write a helper method in JavaScript. It should act differently if one sends in a function or an reference to a function. I want to like to use it like this: helper('div', function () { return false; }) helper('div', obj.fn) What I can't figure out is: how to inside the helper function tell the difference between the two...

Testing the internals of a method with RhinoMock or Moq

Quite new to this mocking thing, I have a couple of questions. Correct me if I'm wrong: Mocking does not initialize the real method i.e. Mocking will not actually call the constructor of your class. Instead it does something like look at the signature of the class and create an object with that signature but with none of the methods fun...

How to check if user is in high contrast mode via JavaScript or CSS

Hi, when pressing Shift+Left+Alt+Print Windows switchs into high contrast mode - is there any chance to detect that on a webpage (using JavaScript or CSS)? Is there any chance to detect that in the HTTP-Request (a.k.a the server-side e.g. via PHP or Ruby)? Cheers ...

How to configure TinyMCE to use absolute paths

Hi, I am trying to configure TinyMCE to use absolute paths, but even though I've tried every trick in the documentation i cant seem to get it working. This is how i have my configuration: tinyMCE.init({ "theme": "advanced", "strict_loading_mode": 1, "mode": "exact", "language": "no", "spellchecker_languages": "+Nor...

how to strech select ?

Hi all, I have a problem with my select .. Default value is "please choose" .. but there are some options like "Acommodation & Hotels" .. so its bigger than the default value .. so its not clearly seen on IEs, it works ok in FF, how can I do this? with css or javascript? what is the best solution ? thank you NOTE : I want to strech the ...

Mocking - setting a property before calling the constructor

In RhinoMocks or Moq, can properties on an object be set before the constructor is called? I'm trying to test a method. The class containing the method has some code in it's constructor which depends on some members being set, unfortunately there's no params in the constructor to set them so I must set them through a property. Is ther...

How do I get a value of a <span> using jQuery?

This is basic. How do I get the value 'This is my name' of the above span? <div id='item1'> <span>This is my name</span> </div> ...

Caching AJAX query results with prototype

I'm looking at putting together a good way of caching results of AJAX queries so that the same user doesn't have to repeat the same query on the same page twice. I've put something together using a Hash which works fine but i'm not sure if there's a better method i could be using. This is a rough snippet of what i've come up with which s...

Using Database storage for uses other than offline apps

I've been looking into offline database storage with HTML5 and the built in Sqlite Db. I think it has a potential for things other than just storing data for offline apps. What I'm interested in, is hearing about potential uses of the database for storing things other than offline web page content. What has anyone in the commnity been u...

Google Maps Tile Overlay

I am currently working on google map and new to it.. I want to know is it possible to divide the map into certain tiles with definite height and width and to color them.. If yes then somebody can just explain how to do it as i am facing difficulties. ...

Some Google Map Markers not showing up in Internet Explorer but show up in all other browsers

Hiya All, I have a Google Map on our site that has a list of markers which are brought in using the following code: $(".map-overlay-right").click(function () { var map = new GMap2(document.getElementById('map-holder')); $("#map-holder").fadeOut('slow', function(){ var gmarkers = []; map.addControl(new GSmallMapControl()...

IE - accumulative events + memory use cause a script error on garbage collector when navigating away

How would you go about profiling a site/script in terms of determining if / what memory leaks occur? Basically, it's a mootools page (which has a built in garbage collector) that sports 2 sort-of cpu-intensive script elements. one of them scrolls some images left to right and back, the other rotates content of 3 elements with some built-...

Store data as Text File from HTML

I want store data from an html page to a text file using javascript on Client Side. Any method is there? ...

how to implement regions/code collapse in javascript

How can you implement regions a.k.a. code collapse for JavaScript in Visual Studio? If there are hundreds of lines in javascript, it'll be more understandable using code folding with regions as in vb/C#. #region My Code #endregion ...

[A-Z]{2,4} not limiting to between 2 & 4 characters

PCRE: /\A[A-Z0-9_\.%\+\-]+@(?:[A-Z0-9\-]+\.)+(?:[a-z]{2,4}|museum|travel)\z/i POSIX: /^[A-Z0-9_\.%\+\-]+@(?:[A-Z0-9\-]+\.)+(?:[A-Z]{2,4}|museum|travel)$/i This regex is correct in every way for my needs except that it allows emails such as [email protected]. It says these are a match. If I'm not mistaken, doesn't the {2,4} after [A-Z] mean th...

Filtering "whitespace-only" strings in JavaScript

I have a textbox collecting user input in my JS code. I would like to filter junk input, like strings that contain whitespaces only. In C#, I would use the following code: if (inputString.Trim() == "") Console.WriteLine("white junk"); else Console.WriteLine("Valid input"); Do you have any recommendation, how to do the same in JavaSc...

Call Webservice from HTML Page

How we can call webservice from html page using javascript ...

Javascript offsetHeight, clientHeight, scrollHeight.. a bug?

Hi, On cnn.com with Firefox 3.5.3, there seems to be a bug with the measurements of document.body. It seems document.body.offsetHeight and document.body.scrollHeight both give the viewable height, thus same as document.body.clientHeight. Same with document.documentElement.offsetHeight and document.documentElement.clientHeight. Only docu...

Client side (javascript/jQuery) file manipulation before/after upload/download.

I'm just sounding things out about this having looked around for a while and drawn a blank. I'd like to see if this is even possible as so far I can't see a way to do it. I want to encrypt a file locally (in the browser using existing libraries) before uploading it. Then I'll need to retrieve it and decrypt it before presenting the file...