javascript

get root URL in javascript

is there a really easy way to turn document.location.href=="http://aaa.bbb.ccc.ddd.com/asdf/sadf/asdf/asdf/asdf/sadf.aspx?blah" into 'aaa.bbb.ccc.ddd.com'? There's gotta be a JS function that does this reliably, but I can't find it. ...

Instantiate an object by calling constructor with parameter list using apply?

Given a function/type declaration like this: function Person(name, ... other args ...){ this.name ... other init code ... } I would like to be able to call the Person constructor with an array of arguments to be applied to it. I could do: Person.apply(this, args) Except that this doesn't instantiate a person, it merely call...

onchange without losing focus?

I'm creating a form with a select dropdown. One of the options is "other - please specify", which is supposed to display an extra text field for more details. I managed to do it using onChange event + some simple value check (as I can't rely on the position). I started testing it and realized that while it works perfectly when using a ...

Is it possible to create a non-centered Javascript alert box?

For a standard Javascript alert() box, is it possible to have it appear in a position other than the center of the screen? Can you specify horizontal and/or vertical position? ...

Internet explorer says Object doesn't support this property or method

This line is 79: window.addEvent('domready', function(){ mySlide = new Fx.Slide('advert'); mySlide.hide(); }); It also does not like this line: this.wrapper = new Element('div', { 'styles': $extend( this.element.getStyles('mar...

JQuery recursive function?

How can I call a function from inside the function, so it becomes recursive? Here is my code, I have added a comment where I would like to start the recursion: $('a.previous-photos, a.next-photos').click(function() { var id = $('#media-photo img').attr('id'); var href = $(this).attr('href'); href = href.split('/'); var p...

Why can't I hit the event handler in the code behind doing a modal popup postback

I am basically trying to do what this article says. link text I am able to postback, but my handler is not getting hit. Any ideas? Code Behind protected void Page_Init(object sender, EventArgs e) { WireEvents(); } private void WireEvents() { btnAuthOk.Click += new EventHandler(btnAuthOk_Click); ...

"this" keyword in event methods when using JavaScript prototype object

Hi everyone, I'm trying to access the member variables of a prototype class in JavaScript in an event handler -- something I'd typically use the "this" keyword for (or "that" [copy of this] in the case of event handlers). Needless to say, I'm running into some trouble. Take, for example, this HTML snippet: <a id="myLink" href="#">My L...

Get mp3 total track time using either javascript or ASP.NET

I am using the below jQuery plugin for playing mp3 www.happyworm.com/jquery/jplayer However, there is a bug in Flash that the total play (track) time won't show up correctly UNTIL AFTER the whole mp3 is completed downloaded. I wonder if there is a way to work around this to get the correct total time using either javascript / another...

JQuery load script on a click event

$('#selector').click(function() { // here I would like to load a javascript file // let's say /js/script-on-click-event.js }); Is that somehow possible? I'm not sure but I remember reading about a function that does this in JQuery documentation but I cannot find it here, maybe it's been deprecated or I saw it elsewhere? Basica...

How do I prevent a parent's onclick event from firing when a child anchor is clicked?

I'm currently using jQuery to make a div clickable and in this div I also have anchors. The problem I'm running into is that when I click on an anchor both click events are firing (for the div and the anchor). How do I prevent the div's onclick event from firing when an anchor is clicked? Here's the broken code: JavaScript var url = $...

3d widget in XULRunner application

Hi all, Does anyone have any experiences trying to include a 3d widget in a XULRunner application? One direction I've been trying is embedding a Java3d applet, but there seem to be a host of problems controlling that applet from the JS of the main application. Another possibility would be if there was some sort of javascript library usi...

Jquery - tell when the hash changes?

Hey SO, I'm trying to make my site respond correctly to the back button. I've saved that hash of what I want it to do, but I don't know the hook for jQuery to be able to tell when the hash changes. It's not .ready(), because the page doesn't reload. What do I use? Edit for a bit of clarity: I'm using an iframe, so I can't tell when...

FireFox / JQuery / Dom : Not returning 'rowIndex.

I am writing a JavaScript function to highlight the row and column of a clicked cell. This function must take into account cells in previous rows that use "rowspan" to protrude down into the selected row - because this causes the cell indexes to differ from the "apparent" index. I.E. every cell in the second column of a table does not ...

Passing JS variable name to function?

Hello all, So here is what I am trying to do: 1.My variable named data_1 is set. var data_1 = { "y_legend": { "text": "# of Patients", "style": "{font-size: 20px; color: #778877}" }, "x_legend": { "text": "AUG 09 - OCT 09", "style": "{font-size: 20px; color: #778877}" } }; In a drop down a user selects an op...

Image Map w/Image-Based Rollovers Bounded by AREA Coordinates, jQuery if Possible

Basically I need this: http://plugins.jquery.com/project/maphilight ...but instead of just having the <AREA> tags recieve a border or fill color on rollover, have them recieve a background image. The image needs to be clipped by the shape of the <AREA>s. Any ideas? Basically the setup I have is as follows: <img usemap="#map" /> <map...

Javascript - getElementById and help me

<script type="text/javascript"> function myfunction() { if (document.getElementById('myform').value == "yes") { document.getElementById('yesinput').style.display = ''; } else { document.getElementById('yesinput').style.display = 'none'; } } </script> <select name="myform" id="myfor...

Sending user to their browser's Home Page using Javascript

Is it possible to get a browser's home page using Javascript? I'd like to place a link on a page that goes to the home page set in the browser. ...

How good is jQuery at coexisting with other Javascript libraries?

I am working on a server-side framework. Here and there I have been adding hand-crafted javascript to do things on the client side. However this is becoming more and more painful and from what I heard I think jQuery can be of help. The issue is that as this is essentially server side stuff, I don't want to obligate my users (assuming ...

JQuery datepicker with time picker?

I am looking for a JQuery DatePicker with a time picker which can work with ASP.NET. I found http://milesich.com/timepicker/ which looks nice but I am getting an 'Error: $("#hourSlider").slider is not a function.. error from their timepicker.js Also found http://code.google.com/p/dyndatetime/ but the time picker is clunky. Any other re...