javascript

Creating an OpenID login widget

I need an OpenID login widget like the one on Stackoverflow or Id Selector (which has been discontinued in favor of RPXnow which is a commercial service). What is the best way to make these? Is there a framework or example implementation anywhere? ...

Call Javascript from function based on condition

I have a jQuery modal system that I have built and would like to trigger the modal to popup if the username or password entered by a user is invalid. I need to do these checks from the C# codebehind in ASP, and then if there is an invalid username or password trigger my javascript function: showModal("errorDiv"). Is this possible? I do...

JavaScript replace/regex

Given this function: function Repeater(template) { var repeater = { markup: template, replace: function(pattern, value) { this.markup = this.markup.replace(pattern, value); } }; return repeater; }; How do I make this.markup.replace() replace globally? Here's the problem. If I use i...

What's wrong with defining JavaScript variables within if blocks?

I have some code like this: if (condition) { var variable = blah; } if (differentcondition) { var variable = blah; } Is this correct? I assume that the variable wouldn't be assigned if the condition doesn't return true. JSLint keeps on telling me, variable already defined. Am I doing this wrong? Thanks. OK, Here's my actual usec...

How can I get a reference to a node directly after it is appended?

I have a situation where I'm appending a node inside an element and would like a reference to it right away. At the moment I do something along these lines: var children = $("#elem").append("<p>hello</p>").children(); var current = children[children.length -1] Can this be done more cleanly with jQuery? I know, I can write a helper...

Need some help with simple JavaScript

Hello everybody. I am very new to the JavaScript, and making only my first attempts to learn. As a small exercise I am trying to so something simple. Pretty much I am trying to reposition button that i have on page load. What do i do wrong? I would appreciate some help. My code is bellow: <style type="text/css"> .mybutton{ position:a...

jQuery fadeIn()

What does it mean if fadeIn() goes from an opacity of 0% to 100% as soon as the fade timeperiod is up? I've got this: function ThreadPost(post, appendToElementId) { if (post != null) { $("#" + appendToElementId).append("<ol id='" + post.Id + "'></ol>"); $("#" + post.Id).hide().html(PostHtml(post)).fadeIn(5000); ...

How can I format the text entered into an HTML textfield like currency?

I have a series of texfields, which I'd like to format as currency. Preferably, this would be done on the fly but at least onblur. What I mean by currency format is 349507 -> $349,507. Is it possible? I prefer HTML/CSS/JS solutions, because I need less explanation. I'm not familiar at all with jQuery. Any help is greatly appreciated.Mi...

Problem with getting a JSON string

Here is my code that sends a form via AJAX and then is meant to display a message back to the user var postValues = { name: $($nameObject).val(), email: $($emailObject).val(), message: $($messageObject).val(), form: $(this).find('input[name=form]').val() }; ...

detect geode, fire eagle, or google gear installed on browser

is there any demo on how to detect geode ,fire eagle, google gear installed on user browsers and get user location? ...

JQuery query string traversal

Possible Duplicates: JavaScript query string get querystring with jQuery Is there an object/method in javascript to turn a string like this: "param1=2&param2=1&param3=5" into some sort of dictionary, so that I can refer to each element as mystring['param1'] or mystring[0]? Can jQuery help here? ...

How can I add an object property to the global object in rhino javascript

I have some properties in an object that I would like to add to the global namespace. In javascript on the browser I could just add it to the window object like so: var myObject = { foo : function() { alert("hi"); } // and many more properties }; for (property in myObject) { window[property] = myObject[property]; } // now ...

pure javascript equivalent of jquery click() ?

Hello, I am building a small apps which has to capture mouse click. I wrote the prototype in jquery. Since it is a small apps focusing on speed, embedding jquery.js to use just one function would be an overkill. I am not very experienced in pure javascript, would you show me some hints on writing pure javascript code to serve this fun...

Jquery: set style part of text in input text

Guys, I want to create some text based on user input, and when user enter some text, the first word will automatically set backgroundcolor, but the other words still remain same (no background color), can I do this ? Thanks ...

How to create a form toggle switch as a replacement for a submit button?

How would one create a form element/button that can be styled/scripted to behave as a sliding/toggle button, similar to: example toggle gif By clicking on the arrow, it would submit the form and change the status to "on" if it was off, or "off" it was on, updating the visual representation accordingly. ...

HTML +CSS +Javascript Editor

Hello a look for a good HTML + CSS +Javascript Editor, can you help me ??? I Use OS Windows Thank you very much !!!! ...

Is there a special meaning of "\h"?

Hey, Does \h have some special meaning? I store the username in a hidden field in my HTML, and all usernames works, but mine (which is DOMAIN\hers....) fails, it ends up like "DOMAINhers...) when picked up by Javascript (JQuery). Any ideas? ...

How to check for duplicate files in php?

What I really want to do is check if the same file exists before or after uploading the file, is there a efficient way to do it? Well, that's it! Edit: Actually it doesn't matter if its after or before, as long as it can detect dups. ...

What is the best way to get a string that fits the provided width in pixels?

I am now facing a problem with getting a string that fits the provided width in pixels. For example, if I have a sentence like this (in JavaScript): var mystring = "This is my sentence, I need to get just 50 pixels from it." If I use the MeasureString method in C# I can get the width: Font font = new Font("Segoe UI", 11, FontStyle.R...

javascript window.parent issue

Hello everyone, I am new to Javascript and after reading related books for quite some time, I am still confused what is the meaning and what is the function of window.parent? Appreciate if someone could show me some simple samples to let me know what does window.parent mean? Thanks! Here is the code I am confused, and it is a part of J...