javascript

How to call object's method from constructor?

Hello, var Dog = function(name) { this.name = name; this.sayName(); } Dog.prototype.sayName = function() { alert(this.name); } I'm creating new instance of Dog object Dog('Bowwow'), but method sayName() is undefined. Why? Or maybe I should do something like (but I can't see difference)... var Dog = function(name) { this.na...

Using a string as an object reference

I currently have a Javascript function that uses a string to reference an object name and acces its properties. I'm currently using eval() to get the the desired effect which I know is very, very wrong. Here is an example of how I'm currently achieving what I want: var stringToObjectRef = function() { var myTestVar = "myTestObject"...

Brightening an image using styles or Javascript

Hello All, I would like to brighten an image on my webpage on mouseover using css or javascript. Ive seen some examples using opacity and filters in styles but they dont seem to work for me. Thanks in advance CP ...

jQuery .change() on Radio Button

Hi folks, I must be missing something obvious here... I can't get .change() to fire on radio buttons? I have the code below live here! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <title>Radio Button...

jQuery click() event; how to prevent this event on right mouse btn click?

Hello, <img src="" width="200" height="200" id="test_img" /> <script> $("#test_img").click(function() { alert("Hello"); }); </script> But it doesn't matter what mouse button I'm pressing - right or left. I see absolutely the same result. I want alert to be shown only on left mouse button click. Thank you and sorry; I'm little n...

how do I automatically execute javascript?

how do I automatically execute javascript? I know of <body onLoad="">, but I just thought maybe there is another way to do it? html: <html><head></head><body><div id="test"></div></body></html> javascript: <script>(function(){var text = document.getElementById('test').innerHTML;var newtext = text.replace('', '');return newtext;})()...

how to change two div-positions on click with javascript

hi folks, i got a webpage with some "cards" (divs) layin on it. they are positioned in a star-like order, flowing to the background. i want to bring cards from the background to the middle-foreground bei clicking on it (to focus the card "contact" for instance). how can i realize this? is there any script which is already containing a...

Is it possible to call a JavaScript function using an array of values as arguments ?

I'm looking for another way of doing the following: function call_any_function(func, parameters){ // func => any given function if(parameters.length==0){ func(); } if(parameters.length==1){ func(parameters[0]); } if(parameters.length==2){ func(parameters[0], parameters[1]); } if(parameters.length==3){ fun...

Where does ASP.Net get its rendered IDs from?

Hi, I've inherited a project with some nasty JavaScript that depends on hard coded object ids. i.e. There are lots of places where it does things like this var magazine = document.getElementById('repModuleDisplay__ctl3_chkCats_0'); When the page renders in my UAT environment, the HTML looks like this, and everything works OK. <inpu...

Call an anchor tag via javascript

Hi all, I am using thick box 3.1 to load a pop up. It working well by using in the following way: <a href="filename.php" class="thickbox"> TEST </a> If we click on the TEST now then the popup is working well and good. Now my prob is: I need to call this popup in form load using JavaScript. I do something like below: <script type="...

Node.js appears to be missing the multipart module

I am trying to parse form data, including upload files with a node.js http server. All of the tutorial type articles I have found use a require("multipart"); to include the multipart module, but when I try the same I get: Error: Cannot find module 'multipart' I also can't find it in the current api docs (though it is in the google cac...

Javascript Iterator Class

Do you know a js library that implements a generic Iterator class for collections (be it Arrays or some abstract Enumerable) with a full set of features, like the Google Common or the Apache Commons? Edit: Enumerable#each is not an Iterator class. I'm looking for an Iterator, something that would let us write something like: var itera...

jQuery plugin DataTables: How to highlight the current search text?

Hi, I have started using the DataTables plugin (v1.6.2) for jQuery(v1.4.2), and I would like to ask you if you know a settings or a plugin that allow me to highlight the text used in search textbox on the filtered rows. Thank you in advance ...

Javascript function working strangely during the first call in CHROME ?

HI all, Below mentioned javascript code works fine in all browsers including chrome(from second call onwards). function call(val){ url = window.location.href; indexnum = url.lastIndexOf("/"); str = url.slice(indexnum+1); window.location.href = url.replace(str, "sample.php?src_q=") + val; } I am ca...

Embed external website inside a page

I'd like to load something from website B into a page on website A and contain the functionality of website B within a container on website A. I tried doing this using a div and jQuery's load() method but I run into cross-domain-scripting issues (I think, it works with a local file but not a remote URL). I also tried using an iframe bu...

Only show activities from a specific gadget in OpenSocial

I created a gadget which is able to post activities: function postActivity(text) { var params = {}; params[opensocial.Activity.Field.TITLE] = text; var activity = opensocial.newActivity(params); opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH); }; And I request activities by doing...

JavaScript regular expression literal persists between function calls

I have this piece of code: function func1(text) { var pattern = /([\s\S]*?)(\<\?(?:attrib |if |else-if |else|end-if|search |for |end-for)[\s\S]*?\?\>)/g; var result; while (result = pattern.exec(text)) { if (some condition) { throw new Error('failed'); } ... } } This works, unless ...

What are the possibilites to embed content from other pages on my own page

Hello this is may first question and I have found so far the following alternatives: ServerSideInclude embedding complete pages via iframe to parse xml and translate into html It would be nice, if you have some more suggestions. Thanks for your patience. Best regards Matthias Günther ...

functions inside or outside jquery document ready

Up until now I just put all my jQuery goodness inside the $(document).ready() function, including simple functions used in certain user interactions. But functions that don´t require the DOM document to be loaded or are only called afterwards anyway, can be placed outside the $(document).ready() as well. Consider for example a very sim...

IE8 and below <input type="image"> value work around

Hi guys, I have a slight problem, I am trying to capture the input of two buttons, one yes, one no, into a database but for some reason the database doesn't always show the value of the button clicked, it just shows up blank. <form action="refer.php" method="post" id="formID" > <div class="prompt_container" style="float: left;"> ...