javascript

Should I use "]]>" or "//]]>" for closing a CDATA section into xHTML

I want to inline Scripts or CSSs into xHTML without escaping special characters. I can do that using a CDATA marked section. According to www.w3.org/TR/xhtml1/#h-4.8 the CDATA section can be defined as: <script type="text/javascript"> <![CDATA[ ... unescaped script content ... ]]> </script> Then, according...

Questions on a snippit of jQuery

Ok, so I am using the facebox plugin. One of the examples given is to trigger the popup, trigger a spinner, do an ajax call, when the call returns replace the spinner with the results. Code is here jQuery.facebox(function($) { $.get('blah.html', function(data) { $.facebox(data) }) }) A few questions. I thought that the jQuery and...

Probably simple jQuery selector question

I have some code right now that executes when a link is clicked. The HTML is structured: <a href='link1'>Stuff<span class='color-bar'></span></a> <a href='link2'>Stuff<span class='color-bar'></span></a> <a href='link3'>Stuff<span class='color-bar'></span></a> With the jQuery like so: $('a').liveQuery('click',function(event){ ... ...

How do you call parent object functions from child objects in javascript

So, I was reading up on John Resig's blog, saw his micro-templating javascript engine and decided to try and implement my own template management system for javascript, to deepen my understanding of prototype inheritance. However, the minute I started writing it, I ran into a problem. To start off, here is my base code: function templa...

Jquery, Jcarousel, first pagination item set to :active unless another is set

I have been able to get the clicked pagination item to respond to a css selector. But I can't get it to be :active if the user uses the next and back buttons vs the pagination. ul.jcarousel-control li a:focus {background-position:0 -11px} ul.jcarousel-control li a:active {background-position:0 -11px} That stuff makes it work if the i...

Include a dynamically created GWT widget in a different Web page

Hi, I have the following requirement: Based on some user input, I need to generate a HTML form that the user can embed on a separate Web application. I thought on doing this with GWT since I'm familiar with it. I'm clear on the input parsing and widget generation part. What I don't know how to do is how to export the root widget's (most...

How should I design my page to allow for dynamic movement of elements on the page?

I'm working on an ASP.NET page where I've got 10 entities. I'll call them Items. An Item can be displayed in one of two modes: Featured or Thumbnail. At any given time there is one Featured Item at the top of the page, and the rest are Thumbnails arranged in a 3x3 grid underneath the featured Item Each item is an ASP usercontrol tha...

Using multiple hyperlinks as submit and input

Need the three "Options" to be hyperlinks that submit the "choice" form. When submitted, I would like the value to be the text of the option selected (i.e. value=Option1, Option2 orOption3) and all three to have the same name. (i.e. name = Options) I saw this and some other posts here, but did not work with my set up - many "hyperlink i...

How to generate the "computed" CSS for an arbitrary HTML code snippet

I am starting work on a project to be able to grab an arbitrary HTML snippet (e.g. all code within a <div></div> block) and generate the minimal CSS necessary to render the snippet on a blank page while maintaining the same visual styling it has on the originating web page. My sense is that all of the heavy lifting for this function can...

Is it possible to make a Polygon clickable using the Bing Maps API?

I can put a pushpin in the center of each Polygon to achieve a "clickable" region but that is an extra step I'd rather not take. ...

Suppose I have a list of 500 thumbnails followed by the title. How do I load the images as the user scrolls down? (JQuery)

In mobile, the internet is slow. If I have a list of 500 images, this is going to take forever to load. I'd like to load the title of the image in a list, but as the user scrolls down, I want to start loading/downloading the <img> tag. How do I use Javascript/Jquery to do this? ...

How to wait for jQuery Ajax requests to complete from WatiN?

I'm writing WatiN tests to test an Ajax web application and have come across a timing issue with Ajax requests. After an Ajax request is triggered by an action on the page, I'd like WatiN to wait until the request is complete before validating that the page was updated correctly. I have a feeling that the solution will involve eval-in...

What is the most optimized or simplest way to reduce a file name in javascript

I recently created a function in javascript that takes in a file name and a max character limit where the result needs to follow these rules: Always include file extension If shrinking occurs, leave the first part and last part of the file name intact. Always replace the removed characters with '...' If file length is under the max the...

Where can I find a list of things that break Javascript in IE 7 & 8?

Some of my scripts work fine in FireFox, but give errors in ie7 & 8. Where can I find resources on how to avoid/fix these errors? For example, I get this error in ie7 & 8 but no error in FireFox 3: Expected ')' ...

IE e.keyCode - How can I differentiate between ampersand and up-arrow?

I am fighting with a very strange javascript behavior on a jQuery UI widget I'm trying to fix. IE7 (win XP), jQuery 1.2.6 (yes, it's an old version). The widget is a combo-box, which captures keyboard events and has special behaviors for the arrow keys. When I try to type the "&" character into the flexbox input field, I get strange be...

jQuery: do I need to put calls to $("img").lazyload() in $(document).ready()?

I am using lazy load jquery plugin. It tells me to put this in my code to activate it: $("img").lazyload(); Do I have to put this in $(document).ready()? or can I just put it at the very top of the page: <head> <script type="text/javascript"> $("img").lazyload(); $(document).ready...{} </script> </head> ...

Is there a way to make jQuery output *actual markup*?

When using jQuery to dynamically build markup, it sometimes becomes useful to have it return the actual HTML that it's generating as a string, rather than as a bunch of jQuery objects. Is there a way to do this? For example, here: $("<strong></strong>").text("Hi there!"); I want to be able to extract the plain-text string "<strong>H...

Which is better to execute window.setTimeout

Which option is better to execute window.setTimeout and why? Option A: window.setTimeout(somefunc,0); Option B: window.setTimeout(somefunc,n); //n may be any number >0 Thanks. ...

Passing Data From Initial XML Request To Subsequent Pages

`I am working with an API that sends back an XML response upon request. Here's a simplified example: <buildings> <building attr1="foo" attr2="bar"> <uri>http://blah.com&lt;/uri&gt; <thumbnail>http://blah.com/foo-picture.jpg&lt;/thumbnail&gt; </building> <building attr1="poo" attr2="pee"> ... </building> </bu...

jQuery Slimbox is not requesting files correctly

I am using jQuery slimbox with it's API. Here is my JavaScript that gets image paths via JSON, and then launches the slimbox via it's API. $('#main-container').append('<span id="check-our-adverts">Check our Adverts</span>'); var advertImages = []; $.getJSON( config.basePath + 'get-adverts/', function(images) { advertIma...