javascript

remembering the class of an element for later

I have a series of link on my pages with random a:hover classes so they display different colors on mouse over. When a link is clicked its set to a different class so that it looks highlighted or active. I need to create a script that first saves the class of the clicked link and then after it is changed and a new link is clicked finds...

jquery reload div X amount of seconds problem

I know there are a million examples and tutrials on how to reload a DIV in jquery every X amount of seconds, here is the example code I am using right now <script> var auto_refresh = setInterval( function(){ $('#notificationcontainer').load('http://localhost/member/beta_new/notifications.inc.php'). fadeIn("slow"); }, 10000); <...

Jquery - Reference by ID - Supposed to return an array?

I just started using jQuery, and various sources suggest that the following should be used to reference an element by ID: $("#imgThumbnail") theoretically making something like this possible: $("#imgThumbnail").src; But my testing indicates that something like $("#imgThumbnail") returns an array, making the following necessary: $(...

Is there a way to get the entire source of a page with yql?

I am trying to load the source of any page into a textbox for a client side only html editor. I need to be able to get the entire source of a web page, not just the body. This yql query returns just the body: http://query.yahooapis.com/v1/public/yql?format=xml&amp;callback=editor.handleLoad&amp;q=select+*+from+html+where+url%3D%22exampl...

Auto Complete Fields in Rails that Display Something Different Than What They Select

Hi, I'm trying to create an auto complete field (using the script.aculo.us plugin) in a form for a category select, but I want the auto complete list to display a number next to each category (the number of other things in the same category). This is similar to the Tags field on stack overflow. Right now I can display the number I wa...

Using a global variable in javascript

How do I do this? My code is something like this: var number = null; function playSong(artist,title,song,id) { alert('old number was: '+[number]+''); var number = '10'; alert(''+[number]+''); } The first alert always returns 'old number was: ' and not 10. Shouldn't it return 10 on both alerts on the second function ca...

JavaScript Replace issues

I have an array of objects that have 2 properties: Key and Value. I have a block of text with placeholders that correspond to the object Keys. I want to replace the placeholders with the corresponding Value from the object with the matching key. I have the following code: function LoadReplacementData(replacementData) { var text =...

How can I hide the jqgrid completely when no data returned?

I'm having a heck of a time trying to only display my jqGrid when records are returned from my webservice. I don't want it to be collapsed to where you only see the caption bar either, but if that's the best I can do, I suppose that I could put a meaningful message into the caption. Still, I'd much rather just hide the grid and show a ...

orkut application development

hi i want to use java script in orkut application development im a newbie and developing the application first time ...

Is there a tool to remove unused methods in javascript?

I've got a collection of javascript files from a 3rd party, and I'd like to remove all the unused methods to get size down to a more reasonable level. Does anyone know of a tool that does this for Javascript? At the very least give a list of unused/used methods, so I could do the manually trimming? This would be in addition to running s...

why does my image roll over behave this way?

My image roll over works... But only one way. function heartOver(id) { if(document.getElementById('heart' + id).src == 'images/heart.png'); { parent.document.getElementById('heart' + id).src = 'images/unheart.png'; } if(document.getElementById('heart' + id).src == 'images/unheart.png'); { parent.document....

Javascript File References Problem (with jQuery)

Before, I had this: <head> <script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript"> var optPrompt = "- Select One -"; var subCats; var parentCats; var nextBtn; var ParentChanged = function() { ClearDescription(); ...

How can I properly escape JavaScript in JavaScript?

This might be something I can't do but... parent.document.getElementById('<?php echo $_GET['song']; ?>') .innerHTML = '<img src="heart.png" onmouseover="heartOver('');" >'; The onmouseover="heartOver(''); portion breaks my JavaScript. Is there a way to escape the quotes so I can do this? ...

Hiding/Showing a swf in a div?

Hi. I have a flex app that I want to hide in a div until the user clicks a link or element of some type. I've noticed that embedding the swf in a div with style display:none does not actually hide the swf, so how would I go about accomplishing this? The goal is to have the flex app loading in the background while the user does other thi...

HtmlUnit property undefined script error

I’m submitting a form using java HtmlUnit package. I am able to get pages and submit forms but on one page I’m getting a ScriptException error. The message is “Cannot set property "disabled" of undefined to "0"” I think it might be caused by a javascript method that tries to set a variable that has not been declared in the form but I’...

How to generate different links on web page if JavaScript is enabled?

I am trying to follow tecnhique of unobtrusive JavaScript / graceful degradation. I'd like to serve page with different links when JavaScript is turned on, and when JavaScript is turned off. For example when JavaScript is turned off the link would be <a href="script.cgi?a=action"> and when JavaScript is turned on <a href="script.cg...

Trying to append to an element using js?

I am trying to add to all <object>'s on a page a snippet of html. I understand I can access elements by tag name and that I can change the element, but can I simple append to it instead? In addition, I want to add it to the contents of each tag, not the end of the document. Which of these methods will work? ...

How do I programmatically set all <object>'s to have the wmode set to opaque?

I have a client who is embedding videos into his WordPress blog. The problem is they have a large CSS dropdown that sneaks behind the flash video. I understand that setting the video's wmode to opaque will fix this, but I obviously need this to apply to every video they upload and not have to go to the HTML to add this tag Is there any ...

javascript regex for whitespace or &nbsp;

I am looking for a javascript regex for whitespace. I am checking several different string in a loop and I need to locate the strings that have the big white space in them. The white space string is built in a loop, like this... please read this code as var whitespace = "&nbsp;" then the loop just concats more non breaking spaces on it...

Javascript Issue on MasterPage

Hey All, I've got a piece of JavaScript that clears the data in a text box. The code works fine on a standalone page, but on the master page its not working. On the default page my JavaScript is: <script type="text/javascript"> function doClear(searchBox) { if (searchBox.value == searchBox.defaultValue) { ...