javascript

jQuery + JSON + Open flash chart, how can I create a chart on the fly?

The JS SWFlocation = "open-flash-chart.swf"; getMyData = function() { $.post( myJsURL, { passedval: 1234 }, function (returned_json) { return returned_json; }, "json" ); } swfobject.embedSWF(SWFlocation, "myChartDiv", "650", "200", "9.0.0", "", {"get-data":"getMyData"} ); Using fir...

What defines the availability of the DOM `document` property in the javascript global object?

I am a bit new to javascript and was trying to understand how the W3C DOM standard and javascript as defined by ECMAscript interoperate. Specifically, as I understand it: the ECMAscript standard defines the existence of a Global Object, which provides functions such as parseInt(string) and explicitly allows the presence of other built-...

How to implement Server push / long polling / comet using PHP and Javascript

How can I implement the comet / server push design pattern using PHP and Javascript? Essentially what I would like is something like this: User clicks a 'submit' button Javascript shows a message like 'Processing 0 / 100 items' Whenever a new item is processed, the php / server pushes out an update, and the javascript changes the mess...

Force Safari form AutoFill entry when using JavaScript to prevent the form's submit

I want Safari's form AutoFill feature to work on the forms in my web app. All of our form's submit events are prevented and instead we send data to the server via XHR (Ajax) POST. The problem is, Safari's default for creating a new entry in it's AutoFill (autocomplete) "database" requires the form's submit event to fire and bubble all t...

close fancy box from function from within open 'fancybox'

Hi all i want to be able to close fancyBox when it is open from within. I have tried the following but to no avail: function closeFancyBox(html){ var re = /.*Element insert complete!.*/gi; if( html.search( re ) == 0 ){ $.fancybox.close(); //alert("foo"); } } foo will open in dialog but will not close down. any hints? ...

clear html page javascript

Is there anyway to delete portions of existing content on a page with a javascript function? Like this: <I WANT THIS CLEARED> <IS THERE ANY JAVASCRIPT OR HTML STATEMENT I CAN PUT HERE> <I WANT THIS DISPLAYED> What should I put in <IS THERE ANY JAVASCRIPT OR HTML STATEMENT I CAN PUT HERE>? I know putting <div style="display:none"><plai...

Is it possible to use the CommonJS libraries yet?

I am interested in getting started with CommonJS. With JavaScript frameworks getting faster all the time, and parsing engines and compilers making JavaScript incredibly quick, it is surprising that a project such as CommonJS has not been initiated sooner. What steps are involved in getting a test project up and running with what has be...

403 error after adding javascript to masterpage for sharepoint.

I am attempting to add highslide-with-html.js from http://highslide.com/ to my masterpage. I am receiving a 403 forbidden error when I use the provided masterpage. I have placed it in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033. Test javascript files such as pirate.js which consists sol...

How often should a web chat client check for updates?

I am designing a web based chat feature for an application that will work sort of like facebook chat or google talk inside of gmail. I'm wondering if anyone has any advice on how often it should check for updates? Every 2 seconds? Every 5 seconds? 10 seconds? Also, should I call setTimeout in the callback function of setTimeout, or in t...

How do I give an HTML canvas the keyboard focus using jquery?

I am implementing a game using Javascript, jquery, and the Canvas tag. How can I prevent the browser from processing keyboard shortcuts when the canvas tag has the focus? I have tried event.stopPropagation() and it has no effect. I can pick up keyboard events. However, when the user presses the spacebar, the web page scrolls down in Fir...

Why should I use string.length == 0 over string == "" when checking for empty string in ECMAScript?

Most of the developers on my current project use a (to me) strange way to check for empty strings in ECMAScript: if (theString.length == 0) // string is empty I would normally write this instead: if (theString == "") // string is empty The latter version seems more readable and natural to me. Nobody I asked seemed to be ab...

replace onmousedown with javascript

Does anyone know how can I replace onmousedown value with javascript? for example: <input style="display:inline" type="text" autocomplete="off" name="endDateAdd" id="endDate" onkeydown="return isNumberKey(event,this)" onmousedown="initCal(this, '{$minCal}', null)" value="{$endDate}"> For the code above, I want to replace onmousedown=...

HTML/JavaScript: Page's focus

I have a shopping cart-like form. When a user clicks on the page, in an empty space, somehow, the "Delete Item" button gets focus. Therefore, if the user clicks somewhere and presses enter, items are deleted from their cart. This only happens in IE. What might be causing this? How can I make sure the only time this button gets focus is ...

jQuery : simulating a click on a <input type="file" /> doesn't work in Firefox?

I've got a web page that looks like this <html> <head> <title>File Upload Click Test</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt; </head> <body> <div onclick="$('input[type=file]').click()" >CLICK SIMULATOR</div> <input typ...

Sending large of amounts of data cross domain

I am wanting to create a mashup where large amounts of data need to be sent cross domain. I am thinking about using IFRAMES. My question is... Will this work?? Does Google use it ?? Does anyone have a concept or some type of psuedo that describes how google does it? I pretty much need to know how to go about doing it. I am using jque...

JavaScript getElementByID() not working

Why does refButton get null in the following JavaScript code? <html> <head> <title></title> <script type="text/javascript"> var refButton = document.getElementById("btnButton"); refButton.onclick = function() { alert('I am clicked!'); }; </script> </head> <body> <form id="form1"> ...

Is this an efficient way to convert HTML to text using jQuery?

I'm trying to convert HTML to plain text. Is it efficient? Am I missing something? txt = $("body").find("script,noscript,style,:hidden").remove().end().text(); Thanks! ...

Javascript OnClick Event - 2 functions

Hello, i used a onclick event for this js function: window.opener.location.href =foobar; After loading foobar in the Parent window this window should close. It is a popup (opended with JS) ...

How to access a form drop down from Javascript

Is there a way to access a drop down options text using JavaScript? For instance I can access the value by doing: document.getElementById("transFrom").value; But I want the text between the option tags. Here is the HTML of a form drop down: <select name="transFrom" id="transFrom" style="width: 300px;" tabindex="1" onfocus="retur...

jQuery scrollTop() doesn't seem to work in Safari or Chrome (Windows)

I've got a simple setup to allow a "help"-style window to be loaded and scrolled to a particular point on the page. More or less the code looks like this: var target = /* code */; target.offsetParent().scrollTop(target.offset().top - fudgeValue); The target of the scroll and the fudge value are determined by a couple of hints dropped ...