javascript

Unit testing a function that does not return anything in Javascript

Hi all: As topic suggested, how can I unit test a function that does not return anything (apart from null checks that simply returns)? And also, how do I unit test the functions within a function which also does not return anything especially if they are at the last lines of a function? The reason behind this question is that I've bee...

JQuery: SlideToggle on links?

How do I perform a JQuery 'slidetoggle' effect using a hyperlink, instead of an input button, as the action item? At the JQuery refence page http://docs.jquery.com/Effects/slideToggle#speedcallback It only gives an example of using a form input button. I would like to have instead of a button, a hyperlink to be the toggle clickable a...

Weird Object Error in Javascript

First, I'm not a javascript developer so I don't have a great deal of experience in this if any. I have a footer I'm inserting into an HTML page using jQuery that has the following code in it that per the client "NEEDS TO BE THERE". <script language="JavaScript"><!-- /************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************...

I can't figure out the bug in this jQuery.

The page having problems is... http://schnell.dreamhosters.com/index.php?page=gallery# I use Firebug to debug my jQuery and other code tidbits and it's been proving very useful for Javascript/jQuery debugging. However, at the same time, it's been one of the most frustrating debugging experiences I've ever gone through. I'm not sure wh...

how to fetch the selected element from a group of available radio buttons from APS.NET MVC application

I have 2 groups of radio buttons with 2 links , corresponding to each of the group, in my ASP.NET MVC application. below attached is the screenshot for better clarity. Now when i select the appropriate link , the value associated with the particular group should be passed on to the contoller Action . for instance in the above case ...

How do I implement observer pattern on PHP + Javascript/jQuery?

Just like in SO, where one is answering a question, if somebody has answered said question, a notification will appear (via AJAX?). My only way of somewhat replicating this is by including a timeout on my script that fetches if there is an update every n seconds. Is there a way to do this using observer pattern on PHP + Javascript (w/ jQ...

Dojo attach event to dynamically created element

I have a form. I include Dojo. Everything works fine. I use Dojo to change the class, values and attributes of input elements based on user input(sort of like validation). The problem is, because of IE, I'm required to create a new input element(that I know of) if I want to change the 'type' of an input from 'text' to 'password'. Once ...

Why does using target="_blank" cause Javascript to fail?

I have a bunch of links that use a target="_blank" attribute to open in a new window. I want to attach Google Analytics goal tracking to clicks of these links. To do this, I tried attaching an onclick="pageTracker._trackPageview('/event/outgoing')" attribute to the links. But I discovered that for links with a target="_blank" attri...

How to create a page which gets real time updates from PubSubHubub

I want to know if it is possible to use javascript/html or php, etc... to create a page that receives continuous updates from a feed that uses PubSubHubub? How can I do this? I am new to this, and any tips would be helpful. ...

How to use jQuery click event to change href value asyncronously, based on a JSON query

I'm using the bit.ly url shortening service to shorten certain url's being sent to a "share on twitter" function. I'd like to load the bit.ly url only when a user actually presses the share button (due to bit.ly's max 5 parallel reqs limitation). Bit.ly's REST API returns a JSON callback with the shortened url, which makes the whole scen...

Need Images to maximize on mouseover in HTML pages

I m have thumbnail images in a table and on mouseover the image i should get as blow up and on mouseout it should be normal thumbnail. and i even need to navigate on clicking the Blowup image. plz guide me with the code of how to do it using javascript or using CSS I need some thing as in this website : link text ...

Use of [square brackets] around JavaScript variables

We have received some JavaScript from an agency that looks wrong, but works. For some reason they are adding [square brackets] around variables, thus: var some_variable = 'to=' + [other_variable]; This works, but the square brackets seem completely superfluous. Is there a purpose to this syntax or is it technically incorrect, but ig...

listbox and javascript to add items

Hello all! I've 2 asp listbox controls and an html input button, and using js i add items (previously loaded from DB) from listbox A to B and it works fine, but when i submit the form, in the code behind the listbox B do not have the item i added accessible. My idea was trying to save roundtrips to the server and make it in client sid...

Javascript to close IE6, IE7, IE8 and Firefox without confirmation box?

Suppose I want to have a link or a button that when user click it, the browser will close without any confirmation dialog box. It will need to work on Internet Explorer 6, 7, 8 and Firefox. ...

Searching for '\' using javascript

I have written a following code to get just the file name without extension and path.I m running it in browser. <script type="text/javascript"> var str=new String("C:\Documents and Settings\prajakta\Desktop\substr.html"); document.write(str); var beg=str.lastIndexOf("\");// **HERE IS THE PROBLEM IT DOESNT GIVE ME THE INDEX OF '\'** a...

how to add double click event on a table row using javascript???

var nextRow = tbl.tBodies[0].rows.length; var row = tbl.tBodies[0].insertRow(nextRow); row.setAttribute('ondblclick', "return move_to_x_graph();"); this code will add a double click event on row.. Right.. But the thing is its not working in case of internet explorer.Its workin fine in case of all the other browsers.. For adding sty...

Are named functions underrated in JavaScript?

Taking the jQuery framework for example, if you run code like this: $(document).ready(function init() { foo.bar(); }); The stack trace you get in Firebug will look like this: init() anonymous() anonymous([function(), init(), function(), 4 more...], function(), Object name=args) anonymous() anonymous() As you can see, it's not very ...

Where is this "Too Many Characters in String literal" message coming from?

Good morning all, I'm sure this is a gimme, but I have no idea where this issue is coming from. I have the following lines in a view: <fieldset> <dl> <dt> <label for="FormTypes">Form Type:</label> </dt> <dd> <% =Html.DropDownList("FormTypes", "All") %> </dd> </...

element onkeydown keycode javascript

Hi I am using this code snippet to add KeyDown event handler to any element in the html form for(var i=0;i<ele.length;i++) { ele[i].onkeydown = function() { alert('onkeydown'); } } How can I know which key has been pressed on keydown event? I try this for(var i=0;i<ele.length;i++) { ele[i].onkeydown = fun...

jquery - Block specific links before a page fully loads and binds click events

I have a modal dialog plugin written in jquery, that binds to the click event of all of the <a> elements with a specific class. The modal dialog 'fetches' a page via AJAX, which is declared under the 'href' parameter of the <a> element. Everything works fine, but - when a user clicks the <a> link before the page was fully loaded and r...