javascript

Adding event handler (with parameters) to element created using document.createElement

In the function below I'm trying to create a dynamic element (textArea). I'm trying to bind a function (resize) to the text area using textArea.onclick = resize; which works fine. What I'd like to do is pass a parameter to the resize function (either the generated id or, if possible, the textArea itself) function addElement(elm, ev...

javascript equivalent of html_entity_decode that doesn't rely on innerHTML?

I'm looking for a javascript version of PHP's html_entity_decode. I found this: function html_entity_decode(str){ var tarea=document.createElement('textarea'); tarea.innerHTML = str; return tarea.value; tarea.parentNode.removeChild(tarea); } However, I can't use this because I need to write this code for an FBML/FBJS Facebook canva...

firebug is erroniously telling me my variable is not defined

I'm setting a breakpoint in the code below where it says "breakpoint". Also adding a watch expression for dataStore. function(){ var self = {}; var dataStore = []; var areEq = UNAB.objectsAreEqual; self.put = function(key, value){ /*breakpoint*/ dataStore.push({key:key, value:value}); } return self; } At this breakpoi...

Is it possible to change the anchornode of a textnode object?

Here's my code: function moremagic() {     var txt = '';      if (window.getSelection)     {         txt = window.getSelection();              }     else if (document.getSelection)     {         txt = document.getSelection();             }     else if (document.selection)     {    ...

How should I verify the page DOM when attaching jQuery/javascript events to elements?

I'm using jQuery to add events to DOM elements. As I do this, I often times use selectors that technically could gather a list of matching items rather than just a single one. e.g. using the .children() and .find() methods I could find 0, 1 or many matching DOM elements. Do I simply need to check .size() == 1 on every element as I att...

Where to put your JS when using an IFrame

Ok, I know everyone thinks IFrames are bad an I know that. But I am "required" to use one for a rare case. So the question I have is when you have an .aspx page that contains an IFrame and then in that IFrame another .aspx page, if you want that .aspx page inside that IFrame to be able to work with JS, should you: 1) Put all your JS i...

Javascript regex problem

I need to make html pages where I want to share Ad space with other adsense users. I am trying to use javascript to find and replace adsense code using regex expression but I am stuck. This is the piece of string I am trying to match. pub-111111111111111"; /* 336x280, created 12/12/12 */ google_ad_slot = "2222222222"; An...

Jquery function creation vs. no library problem

I have code that relies on jquery that works here: $(function() { var referrer = document.referrer; var dataText = 'client='+client+'&referrer='; dataText = dataText + referrer; // Create the AJAX request $.ajax({ type: "GET", url: "http://www.myurl.com/project/thecollector...

Web based screen capture ala userfly.com?

I was checking out http://userfly.com/demo. It captures all mouse clicks and keyboard strokes and plays everything back. How is this done without installing any software? Pure Javascript? It doesn't look like it's using Flash. Are there tools I can use to put something similar in my own site offering it to others? ...

Authentication in Facebook Canvas App using New Graph API

Hello, I am building a Facebook canvas application that loads in an iframe with Django. I would like the login process to work similarly to the way Zynga does it. In this method, if you are not logged in you are redirected to a Facebook login page and then to a permissions request page for the app (without any popups). As far as I can...

What is the Prototype equivalent of JQuery's $(element).text()?

Given the following snippet: <div id="myDiv"> This is my text <span>with a span</span> </div> JQuery can get the interior string with: $('#myDiv').text(); Is there a more intuitive way in Prototype than: $('myDiv').pluck('innerHTML').first().stripTags(); ...

Rating/Voting and Tag APIs, do they exist?

Everyone loves to display Digg/Tweet/Like badges on their websites, and the Disqus Comment System is starting to take over. The benefits of those systems from a developers perspective are: You don't have to program the complex, fully-featured logic that those seemingly simple systems require. You don't have to handle the ...

JS validating barcode scanner data too early

Hello all, I am using a barcode scanner to enter in data and then send the code back to the server to validate it against the database. I'm having a problem of the javascript kicking in after the first character is entered. I need to find a way to delay this so the full 19 charaters can be entered. The barcode I am trying to check conta...

pass javascript variables to form/input fields as onsubmit href link

id like to have an input box that a user can enter a search term into that gets passed to maybe a javascript function that then combines some url segments with the search term creating a full url. up until now its been working fine without a form around it, but i would like to add a form to it so users can just hit enter rather than clic...

How to add reviews and rating to each record (clinic) on webpage, that is store in the database?

Hi everyone! I want to add reviews and rating to each (clinic) record of the database. If people search a clinic, the webpage shows multiple (clinics) records on the webpage, and then user can rate and write review to any clinic or multiple clinics. Then each clinic will show there won rating stars. Like in this link http://search.y...

Javascript string performance comparison

I am working on a jQuery/Javascript app where performance is really important. What would be the fastest way in getting a number value from the following code? Is the same execution time for each cases or does it matter? //Case 1 var number = $("#someID").css("left").slice(0, -2)/100; // Returns a number //Case 2 var number= new Strin...

Disallowing POST BACK when one is already in progress

Disable a post back from asp.net i.e. buttons, links, gridview page index changing and sorting etc when a post back is already in progress. Target browser is IE 6+. I've written these 2 javascript I am not sure how to apply it on GridView Page Index changing. <script type="text/javascript"> //isFormSubmitted variable is used t...

Cannot bind click() event to HTML control

Here's my setup. I'm using .NET: I have a Main.aspx lets call it. That page inherits a master page and the Master Page as usual includes the jQuery library and other includes that we use for jQuery that are global in scope In Main.aspx is an HTML plain vanilla IFrame: In that IFrame is another .aspx page. Lets call it for all tens...

How can I get Eclipse to launch Ant in one keypress?

I changed the keybinding for Run Ant Build to F10 when Editing Javascript Source and also tried In Windows. In both cases F10 opens the file menu. If I press F11 while the ant build.xml is highlighted, it runs. If I press F11 any other time Eclipse opens up the Debug Configuration dialog. If I try Ctrl+F11 it tells me there are no launc...

inner html of iframe object eror

parent.document.getElementById("next").innerHTML=window.frames['hiddenframe'].document.body.innerHTML; Error: window.frames.hiddenframe is undefined this is the error i get. i have given an id for iframes as hiddenframe but still it isnt working. i cant see to find my mistake please help. ...