Hello,
Is there any way to make "private" variables (those defined in the constructor), available to prototype-defined methods?
TestClass = function(){
var privateField = "hello";
this.nonProtoHello = function(){alert(privateField)};
};
TestClass.prototype.prototypeHello = function(){alert(privateField)};
This works:
t.nonPr...
I have the following line of code in a link on my webpage:
<a href="javascript:$('#comment_form').toggle('normal')" title="Comment on this post">
This produces a link that should pop open a hidden form. It works on Safari, but in Firefox, I just get an almost-empty page with nothing but the following text:
[object Object]
I'm sure ...
Hello,
This is a follow up to a question I just posted.
I'm wondering how you all handle member variables in javascript clases when using MyClass.prototype to define methods.
If you define all of the methods in the constructor function:
function MyClass(){
this.myMethod = function(){}
}
You can very nicely declare member variables ...
I have a dynamically created menu which I have a menuItemClick event tied in. In this event I want to execute a simple window.open script that uses the clicked items' url. The reason I need to do this is I need to set the parameters of the window opening (i.e. no scroll bars, no toolbars, etc...).
My question is, is there a way simpl...
I have a page that is currently using the datetime microformat to display a timestamp, but I have only been showing the human-readable time for my own time zone:
<abbr class="published" title="2009-01-09T09:16:00-05:00">
Friday, January 9, 2009 at 9:16 am (EST)</abbr>
What I'd like to do is rewrite the innerHTML for the abbr tag to be...
When embedding JavaScript in an HTML document, where is the best place to put the <script> tags and included JavaScript? I seem to recall that you are not supposed to place these in the <head> section, but placing at the beginning of the <body> section is bad, too, since the JavaScript will have to be parsed before the page is rendered c...
I've ported an Excel retirement calculator into javascript. There are 35 worksheets in the original excel containing many recursive calculations, all of which I've converted to JS. JS is running slower (1-2 seconds compared to Excel's instantaneous). I am caching the resursive calculations already to speed things up and prevent stack ove...
In a client-side web application, I would like to:
open an Excel spreadsheet,
export some application data to Excel,
allow the user to work with it, and
when they are done, read the (potentially changed) data back into my application.
I would like the user to have a fluid experience and detect when they are done with excel by hooking...
I'm trying to use the jQuery alerts dialog library from http://abeautifulsite.net/notebook/87 instead of the default alerts (which look pretty awful in my opinion). This seems to be a great library, but there is not an example of how to use the jConfirm library.
I need to do something like this:
function confirm() {
var result ...
I have a small problem with a script.
I want to have a default action on :hover for those with javascript disabled but for those with javascript enabled i want another action (actually... same action, but i want to add a small transition effect).
So... How can i do this? I am using jquery.
...
Dan Webb's Low Pro UJS extension to Prototype offers the following elegant DOM Builder:
var listItem = $li({ id : 'item-1' },
$strong("Some text")
);
// returns a node equivalent to: <li id="item-1"><strong>Some text</strong></li>
$('a_list').appendChild(listItem);
While this works like a dream for u...
I have the following javascript:
css = document.createElement('style');
css.setAttribute('type', 'text/css');
css_data = document.createTextNode('');
css.appendChild(css_data);
document.getElementsByTagName("head")[0].appendChild(css);
for some reason, in IE only, it chokes on "css.appendChild(css_data);"
Giving the error: "...
import flash.external.ExternalInterface; ExternalInterface.addCallback("asFunc", this, asFunc); function asFunc(str:String):Void { out.text = "JS > Hello " + str; }
send_btn.addEventListener(MouseEvent.CLICK, clickListener); function clickListener(eventObj:Object):Void { trace("click > " + mean.text); ExternalInterface.call("calc", mean...
I'm very new to both the Mvc framework as well as JavaScript and JQuery. I'm trying to understand the right way to structure Ajax calls.
Let's say I have a "Vote Up" button similar to what you see on StackOverflow. When the user clicks it I need to update the vote count in the database and return the new value to the UI. Currently I am ...
I'm trying to fix a bug in a rich text editor I'm using, which causes <embed> tags to be inserted without their closing tag (which screws the output up completely). I've isolated the problem to this operation:
// body is a <body> tag
body.innerHTML = '<embed src="http://example.com/whatever"></embed>';
No fancy code, just Fir...
I'm having to open the firefox error console, which is kind of annoying.
...
Hi,
I'm developing a site using jQuery, and jQuery UI tabs. For some reason, my tabs (unordered list) are showing their bullets in all browsers (tested thus far) except Firefox 3 on OS X. It displays them in Safari OS X, FF 3 Windows, and Google Chrome Windows (IE displays all the divs in a big stack in the corner... but that's anot...
I need to generate many internal client-side (within the company only) graphs from streams of data, and since the data itself is "secret", I can't use a service like Google-Graphs for generating the graphs. So I was wondering if anyone has some recomendations for a javascript graph library that doesn't require a server.
Thanks
...
How do I create a link to set the user's home page to my URL?
...
before posting the whole code, i wanted to make sure I am not missing a simple issue here.
var dv = $(myElement);
var pos = dv.offset();
var width = dv.width();
var height = dv.height();
alert(pos);
alert(width);
alert(height);
here, width alerts fine, height alerts fine but offset alerts [object Object] (in firefox)
am I missing ...