javascript

jQuery Expanding & Collapsing lists

The code expands and collapses a list in which list items can have sublists. Any ideas to refactor this code - especially the toggling part. Is it necessary to use closures here ? $(function() { $('li:has(ul)') .click(function(event){ if (this == event.target) { var that = this; $('li:ha...

Javascript To Get An Alert To Redirect When Closing The Browser Window

Hello Everyone, I'm trying to get this Javascript to work properly. My intention is, when a user is trying to close the site page to get an alert saying "stay on current page or close" If they hit 'ok' I want it to close, if they hit 'cancel' i want it to redirect to another page. The problem is, when they try to go to another page on t...

Showing and hiding a DIV partially

Hi, I need to hide a DIV partially, not totally. When page loads, I want it to show the first, let's say, 100 pixels sitting on the uppermost part of the div. When the user clicks a certain button, the div will open (it could be a sliding effect like jQuery's show()). When the user clicks back the same button, the div will return to its ...

Accessing Oracle DB through SQL Server using OPENROWSET

I'm trying to access a large Oracle database through SQL Server using OPENROWSET in client-side Javascript, and not having much luck. Here are the particulars: A SQL Server view that accesses the Oracle database using OPENROWSET works perfectly, so I know I have valid connection string parameters. However, the new requirement is for ...

Represent a query string in JSON

I have this Javascript data: [{id:123,type:"test"},{id:154,type:"another"}] How would you transform that into something so that I can pass it as a HTTP post request? menu[0][id] = 123 menu[0][type] = test menu[1][id] = 154 menu[1][type] = another I dont want to pass the actual JSON data, I want to clean it up and pass it as formatt...

ajax in each time or load everything at once

you have several links on a page. when clicked, a div gets updated via ajax. the updated div includes data from the database. according to this scenario, every time a link is clicked, the date is grabbed from the database and injected into the div. would you now; 1) support this scenario or... 2) would load each link's content in sev...

Parsing an Int from a string in javascript

In javascript, what is the best way to parse an INT from a string which starts with a letter (such as "test[123]")? I need something that will work for the example below. My JS: $(document).ready(function() { $(':input').change( function() { id = parseInt($(this).attr("id")); //fails for the data below alert(id); }...

Hide header and footer when printing from Internet Explorer using Javascript or CSS

When I print a webpage from Internet Explorer it will automatically add a header and footer including the website title, URL, date, and page number. Is it possible to hide the header and footer programatically using Javascript or CSS? Requirements: works in IE 6 (no other browser support necessary as its for an Intranet) may use Acti...

jQuery: child firing an event for its parent element

Hi, I have several nested div elements like this: <div class="main"> blah blah blah <div class="clickme">clickme</div> </div> <div class="main"> bleh bleh bleh <div class="clickme">clickme</div> </div> <div class="main"> blih blih blih <div class="clickme">clickme</div> </div> I want to fire a toggle event that will show/hide the di...

Comparison between Javascript objects

Hi... I have made a simple accordion for my site using jQuery... It worked great, but I've recently started working on a change where if you click the currently opened segments title (the clickable area to slide up/down), it should close the current section. var sideMenu = { activated: {}, setup: function() { $('...

Can I detect XHTML parsing errors using Javascript?

When I have a markup error in my XHTML page, Mozilla Firefox displays the "Yellow Screen of Death", showing only a large red error message on a yellow background. While these errors are rare, they are extremely user-unfriendly. Is there a way I can detect these using Javascript, and thereby send a message back to the server? What I've...

Recommended JavaScript HTML template library for JQuery?

Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. Thanks in advance. ...

Single page display, multi page print problem

A web page displays the following:- Bob Fred John However when the user (that would be me) prints the web page I want multiple repeats of this output with slight variations to be printed on separate pages :- Bob Fred John >page break here< Bob Fred John >page break here< Bob Fred John In reality the page content is larger...

What is the rationale behind the behavior of constructor pointer in JavaScript?

Considering the simplistic scenario: function Base() {} function Child() {} Child.prototype = new Base; I wonder why would an instance of Child have constructor property set to Base and not to Child? ...

Playing sound notifications using Javascript?

How can I do that, so whenever a user clicks a link we play a sound? Using javascript and jquery here. ...

Hiding Elements

referring to my previous question I came accross to another problem. The div I am showing includes links in it. When I click on them, the div disappears as expected but not as desired.. (we want it to disappear whenever we click on anywhere on page... but the links inside them) the code currently being used: $.listen('click', '.tab...

Subscript text in HTML

Dear All I am Using the following code to write the table, Now i wish to add subscript text,after the table text ,How can it achieved ? My code has oCell = document.createElement("TD"); oCell.innerHTML = data; oRow.appendChild(oCell); how to add a subscript text followed by data ? ...

Can OpenLaszlo Use JavaScript Libraries like JQuery and PrototypeJS ?

I have been looking at OpenLaszlo and observed that scripting in the client is implemented in JavaScript. Does this mean it is possible to use libraries like JQuery and PrototypeJS ? ...

jquery version of array.contains

Can jquery test an array for the presence of an object (either as part of the core functionality or via an avaible plugin). Also, I'm looking for something like array.remove, which would remove a given object from an array. Can jquery handle this for me? thanks, -Morgan ...

using JQuery and Prototype in the same page

Hi, Several of my pages use both JQuery and Protoype. Since I upgraded to version 1.3 of JQuery this appears to be causing problems, because both libraries define a function named '$'. JQuery provides a function noConflict() which relinquishes control of $ to other libraries that may be using it. So it seems like I need to go through a...