(function($) {
$.fn.MyFunction = function(o) {
// Here we have some parameters
return this.each(function() {
[Code].....
So what I'm looking for is how to reference MyExternalFunction from my html script. I've tried simply using MyExternalFunction(index) but I get function undefined.
This question applies to javascript generally as opposed to jQuery specifically. I want to be able to structure my scripts into classes, then create them using the "new" keyword, but here is the important bit: How do I make a js function private (or public for that matter)?
I'm trying to do something, but I don't know if it's possible. Basically, I want to have a public static class method that could access a private object's method. I would like to be able to do :
Class.method(InstanceOfClass);
The method would then access a private function from Class by doing something like
function method(param) { param.privateMethodOfClass(); }
I've done a lot research and experimentations but just can't come up with a solution... I don't even know if what I'm trying to do is possible.
I've just developed a plugin that mimics the combo box control, albeit it's a special one. That's being defined as follows:
function $ { $.fn.extend {
[Code].....
But this isn't possible, since the $myList variable is a jQuery object. So I just defined some functions, say, $.smartList.getSelectedValue and the like... but in this approach, I've to pass the jQuery object to this functions as a mandatory parameter and this really sucks. i.e., I need to get the selected value of $myList this way:
var value = $.smartList.getSelectedValue $myList ;
I have a class hidden by default at the document ready state. I use the show() function when its parent has been clicked and I want to be able to apply a click function to this newly visible element - when I write it I am finding that it is overriding the initial hide(). How do I work around this? I should say that this element is just a bit of text that says "close x" and will be used to "close" its parent div down...
i am working on a page which direct users who come on website to index.php which i created in a new pop up window. i was checking that if someone (stupidly) refresh the url of my web from where he is redirected to the index.php ,it re run the funtion and another pop up is created. is there anyway i can add validation kind of thing that if pop up is created it alert the user that web page already opened. can i able to do that?
I'm trying to convert an on load event into a function. I think this should be really simple, but I'm new to Javascript. The following works fine as the page loads
var favorite = GetCookie('DemoName');
if (favorite > Ƈ') { window.location.href = 'page2.htm' } else { alert('You must complete the lesson before proceeding'); }
I have tried to make it into a function by adding function CookieRedirect() { at the top and a closing } at the end, and calling it using a form button in the body:
My web application does user authentication through X.509 digital certificates in combination with user name and password.
When the user applies for a digital certificate from my certification authority (CA), I have a VBScript code that generates a public/private key pair with the RSA algorithm, as well as the certificate signing request (CSR) in PKCS#10 format. I assume that the key pair should be maintained by the browser (my application support Internet Explorer only at this moment). Am I right?
Now, when the user tries to log into his account, I would like to have my web application receive a digitally signed token from the client. The token can be the client's username signed with his/her private key.
Since this signing process will happen on the client side, it can only be handled by client side script, for example, JavaScript.
But, how do we get access to the private key with JavaScript?
We have a form on our website, which ends up being sent to an e-mail address. The only problem is that some people access this form using public computers. When they press submit , the Internet Mail Wizard pops up and tries to make them setup a new account. Obviously because they are using a public computer we can't have them setting up e-mail accounts on that computer.
I want to be able to set a property on a private object by giving the not notation path to the value. The difficulty is that this object is within closure so I can't access it directly to set the value the normal way (eg. dot.notation.path = 'new value'). This seems weird but I can't think of the obvious way.
Example:
// setter function function set(path, change){ var privateObject = { a: 'a',
I am using the module pattern and private/public methods. I'm having a problem where the private method is using setTimeout() to call itself recursively, but I can't get the syntax right. Code:
I want to call a script from one domain in another domain. How can I *guarantee* that the page calling the script is from my domain and not some hacker/malicious user?The context is that I'm writing my own commenting system, like disqus or intensedebate. They use javascript to imbed your comments (stored on their site) in your site.
Here's how intensedebate's "generic" approach works: You imbed this code into your page:
Code:
<script> var idcomments_acct = 'YOUR ACCOUNT ID'; var idcomments_post_id;
[code].....
The problem is that anyone has access to your accound ID by just looking at the HTML source, so anyone can bomb your account...
so I figured I can track one page of the private website (intranet) through Google Analytics. The way I do this is by creating a page on a public website with just GA code, then putting a 1px x 1px iframe on the private website.
After many trials and errors finding exactly what someone wanted I came up with the solution I wanted for an image rollover. The problem is I put all the code directly into the mouseover/mouseout function. I am not sure how to implement this into two separate Javascript functions to limit the amount of code I have to write. The reason I am not sure how to write the function is because the images are in classes and the results are going to be pulled from a sql query, so they can't have their own id. So, in a nutshell, I just would like some guidance on how to put the mouseover/mouseout code into a Javascript function. Here is my code markup.
I have a question today about making a rollover effect on top of the jQuery Font Effect plugin, like change the gradient color in this Anchor Tag. The code in my JavaScript looks like this.
How can I make a change to this using onmouseover html trigger? I need a function that would change the mirrorColor and color contained in the CSS styles for #seniorpeoplemeet and #realmaturesingles.
1) is getRule a local variable or global variable, as it has no var keyword, yet it is an inner function of Validation? So without var, I think global, but being an inner function, I think local. So I'm not sure which.
2) In this line of code: var rule = $.Validation.getRule(types[type]), getRule returns rules, which is just a local variable in Validation. I always see that you return functions, but how does returning a local variable that's just an object literal and not a function be able to return true or false? Now the value of rules is an object literal, and this object returns true or false. So we are basically allowed to use return keyword with local variables that are object literals and not functions?
3) In this line, is foo(age) being called, or is it just being assigned to bar OR is it being called and THEN assigned to bar: var bar = foo(age);
4) Now for the most confusing: age is obviously an object reference as opposed to a literal in the example. Does that make a difference in regards to closures? Note that I read a number of books, including JavaScript Programmer Reference and Object Oriented JavaScript and jQuery cookbook, which compare primitives vs reference types and how primitive types store directly in memory whereas reference tpyes reference memory, so if one reference changes, they all change where primitive remains ingrained. But when assigning a function as a reference like this, how does that affect the object "age" when passed into bar?
Code: function foo(x) { var tmp = 3; return function (y) { alert(x + y + tmp); x.memb = x.memb ? x.memb + 1 : 1; alert(x.memb); }} var age = new Number(2); var bar = foo(age); // bar is now a closure referencing age. bar(10);
I'm not sure why, but the Console.focus() and Console.writeln() methods just don't seem to be able to use the DOM references stored in Console.STDIN and Console.STDOUT. Everything's fine in the constructor, but other methods can't seem to use them.
I'm about to start a project where the application is one used on a publicly accessed machine. It could be like, say, a ticket purchasing application in a kiosk machine; or maybe touch-screen app that tells grocery shoppers which aisle has coffee, etc.
So my question is, can javascript (or some other language?) be used to open a window without any controls (toolbars, menubars, titlebars, frame, etc) so that the user can't close the application (or resize, change, etc.)?