javascript

Does JSON.parse() require double quoting?

I'm using Firefox 3.5b4. This alerts [object Object],[object Object]: var jsonString = '[{"foo": "one", "bar": 1}, {"foo": "two", "bar": 2}]'; var jsonObjects = JSON.parse(jsonString); alert(jsonObjects); This alerts an empty string, i.e. jsonObjects is null. var jsonString = "[{'foo': '1', 'bar': 2}, {'foo': '3', 'bar': 4}]"; var j...

SP3 installed, vs. SP3 slipstreamed, difference in default security settings?

A Lotus Notes installation, Domino 7x, which ends up trying to start a IBM SameTime 7.5.1 chat client, fails on some machines. Specifically, it fails on Windows XP machines that has SP3 slipstreamed, whereas Windows XP machines which has had SP3 installed afterwards, works fine. The problem can be worked around temporarily by adjusting...

Why do my images not load consistently in my HTML page?

I currently have a website which contains on the main page a list of articles that each one of them has an image next to it. the images are from various different websites. sometimes some images are not loaded, when i check the url of that images it's fine, and when i refresh the page it loads all of them. Is there a way to ensure that ...

JQuery "Constrain" plugin - Weird Javascript Error

Background: Our web app uses the jquery.constrain.js plugin to handle data entry in some text boxes, to only allow valid characters to be added. This plugin allows various constraints upon the data, using regular expressions, whitelist/blacklist characters, etc. Until today, we were running the 1.0 release of this plugin, unmodified. ...

how does a function know where it is located in the DOM?

hi, I'm trying to write a javascript function that adds some DOM nodes to the document in the place it was called, like this: ... <div> <script type="text/javascript"> pushStuffToDOMHere(args); </script> </div> ... i try to do it 'cleanly', without using node id property of the div, or innerHTML string manipulation. for t...

Why would match find a result while test returns false for a regular expression in JavaScript?

I was trying to debug a sorting issue with the jquery plugin tablesorter which uses the following code to check for digits: this.isDigit = function(s,config) { var DECIMAL = '\\' + config.decimal; var exp = '/(^[+]?0(' + DECIMAL +'0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)' + DECIMAL +'(0*[1-9][0-9]*)))$)|(^[-...

TinyMCE: Customize style-names in styleselect-menu

Let's say I have a CSS class named foo but would like it to be shown as foo (1) in the TinyMCE styleselect-menu (one of the default buttons available in the advanced theme). I tried using the class_filter option to do this, but that doesn't seem to work. How would you solve this problem? ...

Get form checkbox values and pass them through pagination?

Hello. I need to get values from selected checkboxe's and pass that values through pagination witch is done by php/mysql. And if on another page user select other checkboxes add their values to array of earlier seleced. I need this for product compare page. In short i get checkbox values store them add checkbox values from other pages ...

jQuery: Validation plugin breaks when changing from jquery 1.2.6 to 1.3.2

I recently upgraded from jQuery 1.2.6 to 1.3.2 Now on the page I'm using the form validation plugin I get the exception: [Exception... "'Syntax error, unrecognized expression: [@for='registration_primary_email']' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "...

What scripting languages are similar to ECMA?

I am looking for an ECMAScript alternative to work as a scripting language for custom application logic. There are things I like about ECMA, especially the syntax for the newer spec(like AS3). Unfortunately, the AS3 engine is not open source to be able to integrate in a project. I would like a scripting language that was designed for ...

Triggering buttons in contained iframe

I have an HTML + javascript page that embeds a page in an iframe. I would like to be able to trigger a submit button (which causes a POST) within the embedded page using javascript in the enclosing page. Is there a library already doing this? ...

JavaScript to add HTML tags around content

Hi, I was wondering if it is possible to use JavaScript to add a <div> tag around a word in an HTML page. I have a JS search that searches a set of HTML files and returns a list of files that contain the keyword. I'd like to be able to dynamically add a <div class="highlight"> around the keyword so it stands out. If an alternate searc...

Is there a javascript library which can be used to filter out strings for XSS attacks?

Is there a Javascript equivalent of libraries like HTMLPurifier, which remove XSS code from strings? ...

decreasing sifr render time

I'm using sifr for a few items on this page: http://blueprint.staging.dante-studios.com/public/templates/home.php unfortunately it seems that the rendering is very slow, does anyone have any idea of how to: a) speed up the rendering process b) hide all "to be sifr'd" items until all of them are ready? ...

Using innerHTML.replace to replace text to create link

I'm using Sharepoint (WSS 3.0), which is unfortunately very limited in its ability to format survey questions (i.e., it strips any HTML you enter). I saw a solution elsewhere that suggested we add some JS to our master page file in order to allow line breaks. This works beautifully, but I'd like to see if we can allow links as well. In...

How do I find "prototype" values in javascript?

I use the following function to detect values that belonged to an object's constructor instead of the object itself. function isAPrototypeValue(object, key ) { return !(object.constructor && object.constructor.prototype[key]); } this would work as follows: Array.prototype.base_value = 'base' var array = new Array; array.custom_valu...

Dragging markers with Ordnance Survey/Openlayers api

I've created a site link text using the api produced by the Ordnance Survey (I think this is called OpenSpace) which is based on OpenLayers. I've got it so you can click on the map to add a marker and I want to then be able to click on the markers and drag it around the map. Is there a simple way to do this using either the OpenSpace or ...

Javascript: what's the point of RegExp.compile() ?

I've got a situation where I want to get a regexp from the user and run it against a few thousand input strings. In the manual I found that the RegExp object has a .compile() method which is used to speed things up ins such cases. But why do I have to pass the regexp string to it again if I already passed them in the constructor? Perhaps...

How to force every page to load a certain javascript file?

I've created a pretty basic system here at work that does what Google analytics does (extremely simplistic in comparison) and it works quite well, but like Google Analytics it requires each page to reference a JavaScript file. Is there any way to make all of our pages that are served from IIS reference this Javascript file? I would like ...

Performance issues in javascript onclick handler

I have written a game in java script and while it works, it is slow responding to multiple clicks. Below is a very simplified version of the code that I am using to handle clicks and it is still fails to respond to a second click of 2 if you don't wait long enough. Is this something that I need to just accept or is there a faster way t...