javascript

Is there a sexier way to write this jQuery selector?

I want to select all the children of the body element before element with id foo (which is a child of body). Since it doesn't look like there are :before() or :after() selectors, I've got it working like this: $('body > :first').nextUntil('#foo').andSelf(); but it seems kludgy. Could this be done with fewer function calls, or more eff...

billboard.js is not working in safari

I have a billboard.js script running on a simple php file and for some reason it works fine in FF and IE but not Safari. I checked source code it and is pulling the content but the scrolling feature does not work when you click. Can someone please help me. Here is the link to try: www.luc.edu/test/cabplan/soc/test.php ...

javascript location.hash refreshing in IE

I need to modify the hash, remove it after certain processing takes place so that if the user refreshes they do not cause the process to run again. This works fine in FF, but it seems that IE is reloading every time I try to change the hash. I think it is related to other things that are loading on the page, though I am not certain. I ...

referencing desired objects in namespaced functions

I'm having trouble referencing the desired object when I've namespaced functions. No problems here: obj.test = function() { // this == obj } But I'm getting tripped up when I namespace: obj.namespace.test = function() { // this == namespace } In the latter example, I know this references namespace, but I want to reference obj....

Fancybox force scroll to top

I'm using the jQuery Fancybox plugin to display some content on a website. Unfortunately, when a link is clicked, the lightbox that is loaded starts at the same scroll position as the previous one. I tried using self.scrollTo(0,0) $.scrollTo(0) $('#top').scrollTo(); and a few others methods to push it back to the top, but ...

What would be the best way to dynamically add a set of rows to a table using JQuery?

I have a following table using MVC that shows number of items the user has. <table border = "1" id="tblItems"> <% var itemnum = 1; foreach (var item in Model.Items) {%> <tr> <td colspan="2" bgcolor="Silver"><strong>Item#<%=itemnum%></strong></t...

How do I retrieve the zero-based index of the selected option in a select box?

Let's say I have the following in my HTML code: <select name="Currency" id="Currency"> <option value="0.85">Euro</option> <option value="110.33">Japanese Yen</option> <option value="1.2">Canadian Dollars</option> </select> Using jQuery, I can use $("#Currency").val() to give me the selectd value, and I can use $("#Curr...

JavaScript Function Definition in ASP User Control

I defined a JavaScript function inside a user control. If I have multiple instances of the user control on my .aspx page, how do I prevent multiple function definitions in the resulting HTML code? ...

Why javascript IF only works one time?

I have javascript code which copy the value of input file and past it in the text box in real time. <script> function copyit(){ var thephoto=document.getElementById('thephoto').value; var fileonchange=document.getElementById('fileonchange').value; if(!thephoto==fileonchange){ document.getElementById('fileonchange').value=thephoto; } ...

how to get all objects of a given type in javascript

I want to retrieve all objects (not DOM elements) of a given type created with the "new" keyword. Is it possible ? function foo(name) { this.name = name; } var obj = new foo(); How can I retrieve a reference to all the foo objects ? ...

Trouble playing a flash movie using javascript in Internet Explorer 8

Hi guys, I´m having a problem trying to play a flashMovie(swf file)... Here is my code: <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" .....> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="false" /> <param name="movie" value="n...

Why is this span above the text? I want it beside the text.

<td valign="center" colspan="2"> <a href="" class="table_desc" > <span class="desc_info_butt"></span> </a> text here </td> .desc_info_butt{ background:url(Description_Button.png) top left no-repeat; height:16px; width:16px; display:block; } For some reason, the image and text appear on two different li...

[JS] XMLHttpRequest problem

I am trying to do "POST" with XMLHttpRequest in a firefox extension, and after that I try to get the "Location" header and open it in a new tab. For some reason, the XMLHttpRequest doesn't contain a location header. My code function web(url,request) { var http = new XMLHttpRequest(); http.open('POST',url,true); http.setReq...

how do I disable options based on the previous selection?

I have three drop-down menus for each sample shirt; product, colour and grade. Not all products are available in all colours and/or grades. I would like to disable the options that are not available based on the users selection. I've tried using this answer here (using a radio select). Unfortunately, I can't get it to work with an opt...

Adding Google Maps "My Maps" feature to own website? - import .kml files

Hello there, I am looking to add the Google Map API to my own website, but I would like to also include the "My Maps" feature which allows a user to import a .gpx, or .kml file and display the data on the map. Obviously it is possible to add just a standard interactive Google Map to a website but is the import fuction possible? Thanks...

customize fb-share button api function

http://www.fbshare.net/implementing-facebook-share/ i need to call a javascript function after share has been successfully completed how can i implement this ? does anybody know that which function in api is being used by fb-share button ...

Help on understanding JS

I have thos piece of code: Math&&Math.random?Math.floor(Math.random()*10000000000000):Date.getTime(); And as far as i know && is logic operator for AND, so im trying to convert this into PHP and this is where i got: intval(floor(time()/10800000)%10+(rand()?floor(rand()*10000000000000):time())) The problem is that i can't understand...

can't log out of facebook from App

I'm trying to logout of facebook from my App using the following code below, but i'm still logged in (and my alert does not execute) also note, this is an external App, using the facebook API. any ideas? FB_RequireFeatures( ["Api"], function(){ FB.Facebook.init(api_key, channel_path); var api = FB.Facebook.apiClient; FB...

Is there a proxy server/apache module I can install that will convert an XML SOAP response to JSON?

I'm connecting to a remote web service which I'd prefer to call with ajax and the service (FedEx Services API) doesn't appear to support JSON formatted responses. Is there a proxy server/apache that will convert the response from XML/SOAP into JSON so my Javascript can easily use it? ...

Is there a more elegant solution than an if-statement with no else clause?

In the following code, if Control (the element that trigers Toggle's first OL) is not Visible it should be set Visible and all other Controls (Controls[i]) so be Hidden. .js function Toggle(Control){ var Controls=document.getElementsByTagName("ol",document.getElementById("Quote_App")); var Control=Control.getElementsByTagName("...