javascript

JavaScript prototype(ing) question

Trying to grasp Prototyping in Javascript. Trying to create my own namespace to extend the String object in JavaScript. Here is what I have so far (a snippet): var ns { alert: function() { alert (this); } } String.prototype.$ns = ns; As you can see, I am trying to place what will be a series of functions into the ns namespace. So...

IE6 javascript can't get height by document.getElementById(id).offsetHeight

Hey guys, I just got a problem which is I can't get the height property of a <p>.(use javascript document.getElementById(id).offsetHeight) It works fine both in FF or chrome. I have tried to set the style of the <p> to height:100%;/height:auto; but both not work. Please help me, thanks :D UPDATE: It seems that IE6 didn't return the...

JavaScript - Settting property on Object in Image load function, property not set once outside function

Sometimes JavaScript doesn't make sense to me, consider the following code that generates a photo mosaic based on x/y tiles. I'm trying to set a .Done property to true once each Mosaic image has been downloaded, but it's always false for some reason, what am I doing wrong? var tileData = []; function generate() { var image = new Im...

Tag-like autocompletion and caret/cursor movement in contenteditable elements.

I'm working on a jQuery plugin that will allow you to do @username style tags, like Facebook does in their status update input box. My problem is, that even after hours of researching and experimenting, it seems REALLY hard to simply move the caret. I've managed to inject the <a> tag with someone's name, but placing the caret after it s...

How to export javascript generated report to pdf?

Hello... I made a reporting engine with javascript for my project... The problem is with printing.. Although with page-break and css i can produce a good looking report, i want to export that report to a pdf in order to be printed better without ,the url,page title and other stuff that browsers add. Note in Chrome there isnt page setup!!...

Bind event to shape on canvas

How can I bind an event to a shape drawn on a canvas? I presumed this would work but I get an error. <html> <head> <script type="application/javascript"> function draw() { var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); ctx.fillStyle = "rgb(200,0,0)"; ...

Is there any javascript charting available that is as good as flex charting?

I am looking to replace my flex application to support IPad. Are there any good charting components that I can build using javascript to replace my flex charting components? and are they any good? ...

Php/Javascript to make a browser game?

I've been on and off intrested in making a text based browser game. I have been turned off by the idea because of the daunting amount of things to learn. PHP (or another sever side scripting language) Javascript HTML MySql And the fact of severs and apache.. Can I just pay for web hosting and by-pass having to set-up apache? Also ho...

Making ExtJS Window maximize animated?

Hi, My question is simple: is there a way to animate the maximize of ExtJS windows? Currently my windows just maximize without any animation and it looks "boring". ...

Get IFrame parent url or referrer using javascript or php

I am creating a widget that would load in a IFrame and users will be able to place the widget on their own website. How would I get the URL of the website that is using the IFrame in javascript and/or PHP? The IFrame loads a php file. I have tried "parent.top.location.href" and "parent.document.referrer" in the IFrame page but that is u...

How to get a Javascript routine to NOT act if it's in a text box?

I've got a simple page, and in that page runs a simple jquery keypress routine to catch clicks of the numbers 1 to 9 (has to be that to pass RNIB accessibility test). And in that page is a form, which can have numbers entered as part of a postcode. http://find.talking-newspapers.co.uk/result.php?addressInput=kingston Scroll to the bot...

Using jQuery to disable function untill all selects are changed

I am using a javascript function (F) (jquery )which uses 3 select values selected by the user to calculates a value - R(result) R is a number ranging from (1 through 9), (11) and (22); I need 2 extra steps one before the calculation and one after. a. Before calculation takes place: Make sure all three select values are changed before ...

Monitoring XHR requests on Chrome in Linux

Is there a way to monitor AJAX requests in the Chrome browser? I tried firebug lite, and though it seems to work for some things (javascript errors and such), the XHR tab doesn't seem to do anything. Are there any alternatives? ...

What's the best way to display a blown-up image using minimal JQuery?

The Goal: On mouseover (or :hover), enlarge the preview image by about 400% and display it in the center of the page Remove the preview when the mouse leaves The Problem: Solutions like FancyBox are too bloated in FancyBox's case it ignores width and height for image elements, which makes it useless Most of these "lightboxes" ste...

Facebook "Like" button callback

Hello, I am interested in implementing the facebook "Like" button, but I would like to know what user is clicking on this button so I can get some useful information from this. From what I have read, facebook is leaving us in the dark on who is clicking on what. ANyone have an idea on how I could track which user clicked on a like button...

YUI Calendar: how does it load the Sam's Skin CSS?

I'm using YUI 2's calendar in YUI 3. How does it load Sam's skin CSS? I didn't manually include it (though it seems like I should so the user can download it in the one request I make to the combo loader for css). Strangely, I don't see it being downloaded nor do I see it in the JS files themselves. I must be overlooking it. This is...

Can someone explain this javascript code to me?

var vTableExp = "//a[contains(@href,'newdid')]/ancestor::td/ancestor::tr/ancestor::tbody"; var vTable = dom.find(vTableExp, XPFirst); thanks ...

Ordered hash in JavaScript

JavaScript objects have no order stored for properties (according to the spec). Firefox seems preserve the order of definition of properties when using a for...in loop. Is this behaviour something that I can rely on? If not is there a piece of JavaScript code somewhere that implements an ordered hash type? ...

JavaScript to PHP

I am trying to send a variable from a Javascript to a php script but what gets sent is just the first string and the rest is discarded.Dont know what i would be doing wrong. Here is my code: <script type="text/javascript"> document.write(<li><a href=../../../../projects/sungrant/view/HistoricalCategory2.php?category=Historical Category ...

Dynamically alter outter div as inner one gets bigger.

I have two divs, one inside another. The outter one is called #wrapper, while the inner one is called #pad. Now #pad allows user input, and I have a javascript (jQuery) function that changes the content of #pad based on what the user input is. Sometimes, because of this function, #pad's content will cause the div to become more elongat...