javascript

Setting an XSLT variable as a javascript variable?

How would I grab an XSLT variable and use it to set a javascript variable? I'm working on a bit of AJAX and in order to make it work to the fullest I would like to be able to grab XSLT variables and use those to set the default values of some javascript variables that I'll then be manipulating with jQuery. ...

Regular Expression matching either a single special character OR a particular sequence

Not sure if I'm doing this right: /(https?:\/\/\S+)(\s|(& nbsp;))?/g; This should match a URL beginning with http(s):// and ending with a space character or a & nbsp; So the problem is this part: (\s|(& nbsp;))? That should mean: match either a white space or a & nbsp; but it doesn't work. It never matches for a & nbsp; and just c...

Why is a variable not being reset in my event handler?

Here's my code: $(document).ready(function () { var default_var = 2; var show_var = default_var; var total_var = 8; var increment_var = 2; var start_var = show_var+1; var end_var = show_var+increment_var; $("a[rel=more]").live("click", function(){ $("#timeshare-listings li:last").after("<li class='aj...

Strange characters showing up in XML > ASP.NET > Javascript > HTML

Hi, i have a script that reads an xml file then produces some document.write javascript lines and sends them to request . I'm getting a weird character (only shows in internet explorer, not firefox). I can't seem to track it down. Here's a URL of the script being used (has weird chars in IE): http://www.voyagertravelguides.com/test....

jquery id getting help

i want to put the id into the colorbox below this code nom works but the page with the link on it is $("#recent_activity").load("activity.php?id="+id+"&random=" +unique_requestid()); thats how it calls the page and the link is on that page. var id = $.query.get('id'); $("a[href='write_comment.php?act=write&id="+id+"']").colorbox(...

Javascript/jQuery string manipulation?

I'm trying to either grab only part of this URL or inject part of a string into it (whichever is simplest). Here's the URL: http://www.goodbuytimeshare.com/listings/min:1000/max:150000/agreements:rent,buy/properties:apartment,condo,hotel,resort/show:4/ I figure I either need to be able to tim it down to: /listings/min:1000/max:15000...

jQuery newbie: how can I pass arguments to an event handler function?

I'm looking at the example for the "click" event in the jQuery documentation here. I can refactor the two anonymous functions as follows and it still works: $(document).ready(function(){ $("p").hover(hilite, remove_hilite); }); function hilite() { $(this).addClass("hilite"); } function remove_hilite() { $(this)...

why does this javascript crash safari but not firefox?

I have a pane with a set of javascript-generated tables, each with a unique ID and 4 cells, and I use the following Javascript code to set the background color for one of these tables. It works fine in Firefox, but it crashes Safari the first time it tries to set the background color (in the if statement). Any ideas why? <script languag...

What exactly does one use JQueryUI for?

I'm a bit confused about the exact use cases for jqueryui. What do you use it for? And why? ...

How do I create a show full screen button to toggle my google maps page to be full screen?

Hi guys I have a google map integrated on part of my page and I would like to create a toggle button to toggle the map between full screen and normal size. So when you click on it - the map extends to fill the whole browser screen and click on it again it is restored to its original size on the page. How would I do it? ...

Multiple Dashboard widget instances don't survive widget update. Any way to prevent this?

I've written a Mac OS X Dashboard to show the StackOverflow flair of yourself and other people. My problem is that whenever I update that widget to a new version, all previous instances are removed and a single new instance is created on the Dashboard. So if you previously followed the flair of 4 people you'll have to recreate the widge...

How can I replace (wrap) methods in new methods programmatically?

I have several methods that I need to wrap in new methods in basically the same manner. My first solution doesn't work, and I understand why, but I don't know if there is a simple solution to this problem or if it can't be done the way that I want to do it. Here's an example. I have objects a-c that have an onClick method. I need to exe...

position a div to the right of a centered div?

I have a which is in the center of my page, but now i need to add a div which will be to the right of the center box, i am sure you can do this with CSS but can't think of a solution. So for example div#container{margin-left: auto;margin-right: auto;width: 396px;display:block;margin-top: 110px;} the div i need would be the same as tha...

How to calculate file upload and download time using asp.net C#

I have a scenario in which need to calculate the Server Time for uploading files as per the Connection speed. Example: Need to calculate time to upload files with Connection speed 256Kbps and more If connection breaks then checking the remaining time and restart the download or upload operation where it was break ...

How to transform an HTMLCollection object to a String with XML?

What is the best way to get the full String representation of an HTMLCollection object in javascript/jquery? The output String should have an XML syntax. ...

How to limit users to Login?

I have a scenario in which I have to restrict the users for login as per following details: Whenever 500th user try to login My web-site there would be a message "User login exceeds, please login later!". Only 499 users can login at a time, 500th user is the Admin. Also need to show online users in admin page-view. So, how to calculate...

Firefox and UniversalBrowserWrite privilege

If I try to write: netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite'); Firefox 3 tell me that to my script have been negated the UniversalBrowserWrite privileges! Now I want to execute in my LAN a program that is maximized in a fullscreen mode and I want to use privileged statements for the windows as toolbar...

need a reliable alternative to String.fromCharCode

function randomString( len ) { // A random string of length 'len' made up of alphanumerics. var out = ''; for (var i=0; i<len; i++) { var random_key = 48 + Math.floor(Math.random()*42); //0-9,a-z out += String.fromCharCode( random_key ); } window.alert(out); return out; } As far as I can tell the result of String.from...

How to make "webmail"-like file attaching/uploading

Hello I want to implement file uploading with behaviour which is commonly seen in various kinds of webmail interfaces. I mean here that attachment (one or more) are selected by open file dialog and then their names are apearing under (for example) text area with body of message. And there is only info that attachment is added and it be ...

What does this Javascript code do?

I ran across this snippet in an internal web site, but I'm having trouble understanding it: function safeWrap(f) { return function() { setTimeout.apply(window, [f, 0].concat([].slice.call(arguments))); }; } Later on, it's used like this: // Set click handler. (...).click(safeWrap(function() { ... } )); What is this meant to...