javascript

Call onresize from ASP.NET content page

I have a JavaScript method that I need to run on one of my pages, in particular, the onresize event. However, I don't see how I can set that event from my content page. I wish I could just put it on my master page, but I don't have the need for the method to be called on all pages that use that master page. Any help would be appreci...

Scripting SVG

I'm considering developing a website similar to stackoverflow, but the answers may also consist of drawings (schematics, in this case). I want to have an area in the answer form where they can make this schematic without requiring special plugins, etc. Are we to the point where SVG has or should have critical mass soon (1-2 years) s...

Is it possible to call Javascript's onsubmit event programatically on a form?

In Ruby on Rails, I'm attempting to update the innerHTML of a div tag using the form_remote_tag helper. This update happens whenever an associated select tag receives an onchange event. The problem is, <select onchange="this.form.submit();">; doesn't work. Nor does document.forms[0].submit(). The only way to get the onsubmit code gen...

Determining width of a printed string by a webapp

In my (PHP) webapp, I have a part of my site that keeps a history of recent searches. The most recent queries get shown in a side box. If the query text is too long, I truncate it and show ellipses. Eg: "My very long query is..." Currently, I truncate after a certain number of characters. Since the font is not monotype, a query of all I...

Checking if userinput is a valid URI in XUL

Is there an built-in function/method that can check if a given string is a valid URI or not in the Mozilla XUL toolkit. (I have looked for one but found none, but since this is my first time using XUL and it's documentation it could be that I just overlooked it. So I'm just making sure before I start writing my own IsValidURI function) ...

What's the best way to add event in JavaScript?

I see mainly 2 ways to set events in JavaScript: add event directly inside the tag like that: <a href="" onclick="doFoo()">do foo</a> Or set them by JavaScript like that: <a id="bar" href="">do bar</a> And add event in a <script> section inside <head> or in an external JavaScript file, like that if you're using prototypeJS: Ev...

What is in your JavaScript development toolbox?

I have to do some JavaScript in the future, so it is time to update my toolbox. Right now I use Firefox with some addons: JavaScript Shell from https://www.squarefree.com/bookmarklets/webdevel.html Firefox Dom Inspector Firebug Greasemonkey Stylish I plan to use Venkman Javascript debugger as well as jsunit and js-lint. For program...

What more is needed for Ajax than this function

I have a small JS function that does Ajax for me and another like it that adds in POST data to the request. With Ajax being such a big topic with so many libraries about it, what am I missing from my function, is it insecure or something else worrying? function loadPage(pagePath, displayElement) { var xmlHttp; try { // Firefox, Op...

How do you swap DIVs on mouseover? (jquery?)

This most be the second most simple rollover effect, still I don't find any simple solution. Wanted: I have a list of items and a correspoding list of slides (DIVs). After loading, the first list item should be selected (bold) and the first slide should be visible. When the user hovers over another list item, that list item should be se...

Making an iframe take vertical space

I would like to have an iframe take as much vertical space as it needs to display its content and not display a scrollbar. Is it at all possible ? Are there any workarounds? ...

Best practices with jQuery form binding code in an application

We have an application with a good amount of jQuery JSON calls to server side code. Because of this, we have a large amount of binding code to parse responses and bind the appropriate values to the form. This is a two part question. What is the reccomended approach for dealing with a large number of forms that all have different data. ...

duplicating jquery datepicker

the datepicker function only works on the first input box that is created. i'm trying to duplicate a datepicker by cloning the div that is containing it. <a href="#" id="dupMe">click</a> <div id="template"> input-text <input type="text" value="text1" id="txt" /> date time picker <input type="text" id="example" value="(add date)" /> </d...

How to transform a WebService call that is using behaviours?

We have some really old code that calls WebServices using behaviours (webservice.htc), and we are having some strange problems... since they've been deprecated a long time ago, I want to change the call. What's the correct way of doing it? It's ASP.NET 1.1 EDIT: Please stop re-tagging when it's not needed. Refer to the FAQ ...

Comparison of Javascript libraries

After the suggestion to use a library for my ajax needs I am going to use one, the problem is that there are so many and I've no idea how to even begin telling them apart. Thus, can anybody A) Give a rundown of the differences or B) Point me (and others like me) somewhere that has such a list. Failing that plan C is to go with whichever...

On a two-column page, how can I grow the left div to the same height of the right div using CSS or Javascript?

I'm trying to make a two-column page using a div-based layout (no tables please!). Problem is, I can't grow the left div to match the height of the right one. My right div typically has a lot of content. Here's a paired down example of my template to illustrate the problem. <div style="float:left; width: 150px; border: 1px solid;"> ...

How do I set the name of a window in ROR?

How do I "name" a browser window in ROR, such that I can open a page in it later, from another (popup) window (using the target="name" html parameter) ...

How do you make a post request into a new browser tab using JavaScript / XUL?

I'm trying to open a new browser tab with the results of a POST request. I'm trying to do so using a function containing the following code: var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interface s.nsIWindowMediator); var browserWindow = windowManager.getMostRecentWindow("...

Replacing the nth instance of a regex match in Javascript

I'm trying to write a regex function that will identify and replace a single instance of a match within a string without affecting the other instances. For example, I have this string: 12||34||56 I want to replace the second set of pipes with ampersands to get this string: 12||34&&56 The regex function needs to be able to handle x...

Fixed Legend in Google Maps Mashup

I have a page with a Google Maps mashup that has pushpins that are color-coded by day (Monday, Tuesday, etc.) The IFrame containing the map is dynamically sized, so it gets resized when the browser window is resized. I'd like to put a legend in the corner of the map window that tells the user what each color means. The Google Maps API ...

Firefox vs. IE: innerHTML handling

After hours of debugging, it appears to me that in FireFox, the innerHTML of a DOM reflects what is actually in the markup, but in IE, the innerHTML reflects what's in the markup PLUS any changes made by the user or dynamically (i.e. via Javascript). Has anyone else found this to be true? Any interesting work-arounds to ensure both beha...