javascript

Facebook, Omegle, Major Chat Applications Title Change on New Message

My question is, how does Facebook, Omegle, and major chat applications code the title change on new message system. I want to, on change of a div, to change the <title> tag to something else than it already is set as. This is most likely accomplished in Javascript, but I'm not an expert in Javascript, so how is this written? ...

Add thousand separators to output from jQuery Slider plugin

I'm using the jQuery Slider plugin (jqueryui.com/demos/slider/) I'm calling the plugin with the following Javascript: $(function(){ $("#slider-price").slider({ range: true, min: 0, max: 5000000, step: 100000, values: [0, 5000000], slide: function(event, ui) { $("#amount").val('£' + ui.values[0] + ' - £' + ui.values[1]); ...

Keeping the format of pasted text in a textarea without visible mark-up info.

I had a case where i copied bold text from a web page into a textarea of another page. On paste, the text area kept the text's bold format. When i pasted the same text into a text file i could see no mark ups or formatting info along with the text. How is the textarea keeping the format of the text? Thanks in advance. EDIT: How i...

Need jQuery code to append parameters to all urls contained in a div

I need a jQuery code snippet which appends the parameter action=xyz to all urls within a page - note it should also check that if the urls already have other parameters appended or not: e.g., for a url such as index.php?i=1 it should append &action=xyz and for urls without parameters like index.php it should append ?action=xyz. ...

Why does the existing hidden rows are not displayed when I added two rows to the jsp in Firefox3.6?

I have added two rows to a jsp which are displayed one at a time based on the text entered. There are two other rows which are already existing and they are displayed based on their own conditions not related to my changes. All this process works fine in IE6, Chrome, Opera 10 and Safari 4. Except Firefox 3.6: my two rows are displayed as...

Why does string.split() behave differently for Regular Expressions?

In JavaScript, if I run the following code: <script type="text/javascript"> var nameStr = 'Chris Kate Steve'; var names = nameStr.split(/[ ]/); var names2 = nameStr.split(' '); for (var i in names) { alert(i); } for (var i in names2) { alert(i); } </script> It will alert: 0 1 2 index input For the f...

Ways to circumvent the same-origin policy

The same origin policy I wanted to make a community wiki regarding HTML/JS same-origin policies to hopefully help anyone searching for this topic. This is one of the most searched-for topics on SO and there is no consolidated wiki for it so here I go :) The same origin policy prevents a document or script loaded from one origin ...

How can I check if a facebook like button has been clicked?

I've put facebook like buttons into my wordpress blog... the idea is to use them as kind of a voting mechanism for posts. What I would like to do is automatically add a comment for the blog post everytime someone 'likes' it via the facebook like button. So my question is- does the like button api provide some kind of a callback to my pa...

jQuery Ajax Get not working

Hello, going to http://revyu.com/sparql?query=SELECT+%2A+WHERE+%7B%7D works totally fine by returning an XML file, but as soon as I use jQuery, I'm getting errors: var sparql="SELECT * WHERE {}"; var query = 'http://revyu.com/sparql?query=' + escape(sparql); $.ajax( { dataType: "xml", url : query, success : f...

Is there a way to change the prototype from within a function in Javascript?

I have this type of code for prototypal inheritance in Javascript. function A() { this.a = 1; } function B() { someEl.innerHTML(this.a); } B.prototype = new A(); However, I am wondering if there is a better way to do it, preferably one that brings the prototype declaration into the declaration of B. I tried setting this.proto...

How to know when a textbox changes (without waiting for blur)?

I have an <input> textbox. I wish to call a function when it has been modified. The default behavior of the change event is to only trigger on blur, but I need to call my function as soon as the textbox's text changes and can't wait for blur. I'm not sure the best way to do this. I thought of maybe handling keydown and then testing th...

"XMLHttpRequest Exception 101" on nested AJAX queries

I'm doing an AJAX fetch of a binary file the I am parsing in javascript. (Quake 2 BSPs, if anyone cares.) The code to fetch and parse the initial file is working fine, and looks roughly like this: function loadFile(url) { var request = new XMLHttpRequest(); request.onreadystatechange = function () { if (request.readySta...

Microsoft Web Protection Library Can you have your own whitelist? + other questions

Hi If the Microsoft Web Protection Library can have custom white-lists http://wpl.codeplex.com/ I am also wondering do you need to do anything special to get it to work with asp.net mvc? I am going through it's methods and I see AntiXss..::.GetSafeHtml AntiXss..::.GetSafeHtmlFragment Method AntiXss..::.HtmlEncode Method AntiXss.....

HTMLDivBalloon - Google Earth API Question

Dear all, I have a problem using balloons in google earth. I have some markers on the map, upon clicking on a marker, a balloon popup is shown containing some data, now when I click on the close button of that balloon, the click event of the map is also triggered which is really annoying as I have a handler attached with the map click e...

embedded Media Player Problem

I have a Media Player (type application/x-mplayer2) embedded in my website, which plays a .M3U file playlist of .MP3 files with Album Art embedded in each file. I would really like to have the Album Art for each .MP3 displayed when the player plays the .MP3. Could someone show me, or direct me to, the code for this display? tqasolutio...

How to stop onclick event in div from propagating to the document?

I want to stop propagation of this div's onclick event to the document? When the user click on the "div", both alerts appear: 1) the div's alert and 2) the document's alert. I want to suppress the document alert. I know how to do it using addEventListener, but is there another way to to do it? The problem below is that I don't know h...

javascript onclick="location.replace('url')" not working

i'm writing some inline javascript. it's not working and i'm not sure why. at the top of the index page <meta http-equiv="Content-Script-Type" content="text/javascript" /> later on i have: <select name='id'> <option value=-1>New Entry</option> <option value='1' onclick="location.replace('index.php?page=update&id=1')">2010-06-12 ...

JavaScript event registering without using jQuery.

How to correctly do something like the following without using jQuery. $(document).ready(function(){ $("#someButton").click(function(){ alert("Hello"); }); }); Thanks. ...

Date.JS parse isBefore problem

Hi, Im using date.js to compare to dates that are written in user friendly string form(Sat, 1 July 2006 12:34:14). I use this code. function is_new(lasttime, newtime){ lasttime = Date.parse(lastime); newtime = Date.parse(newtime); if(lasttime.isBefore(newtime)){ return true; }else{ return false; } } ...

Check to see if certain fields have been filled out before a form is submitted.

Hi all, I have a form that is sending data to a MySQL database and I want to make sure several of the fields are not left blank. I think I can figure out how to do this with JavaScript, but my question is should I? When I made the database table that I am working with I made the fields that I want to make sure are filled out NOT NULL t...