javascript

Too many characters in character literal

I am adding some script using the StringBuilder. The script is as shown below. <script type='text/javascript'><!-- //<![CDATA[ var m3_u = (location.protocol == 'https:' ? 'https://rre.rrt.com/sss.php' : 'https://rre.rrt.com/sss.php'); var m3_r = Math.floor(Math.random() * 99965449); if (!document.MAX_used) document.MAX_us...

jQuery "modify" event

So I recently took a closer look at JavaScript and jQuery and after that stumbled over the Firefox extension called Greasemonkey. Well, let me explain what I mean with the "modifiy"-event: I've got 2-3 userscripts for a certain page installed which automatically look if the page has changed in any way and if it has, they load the new co...

Parse Javascript to instrument code

Hi, i need to split a javascript file into single instructions. For example: a = 2; foo() function bar() { b = 5; print("spam"); } has to be separated into three instructions. (assignment, function call and function definition). Basically i need to instrument the code, injecting code between these instructions to perform che...

jQuery - farbtastic PlugIn callback function

Hey! I'm just setting up a web page with a color picker. I choosed farbtastic. My problem is, that the callback function doesn't work. Here is the code I used: $('#colorPicker1').farbtastic('#background-color', function callback() { /*commands*/ }); The callback function is not called, when the user choosed a color. Does someone ha...

How to replace Dom element in place using javascript?

for an element in DOM,such as an "A" element,how to replace it with a "span" instead? ...

Using JSON from Processing-JS

OKay, I'm a bit of a javascript n00b, so forgive me if this seems like an obvious question. I want to write an application using processing-JS, and I'd like to be able to load it with server-side data. I haven't written the server side yet so I can use anything, but it seems the obvious AJAX thing would be to use JSON to upload the d...

Javascript Regex and Submatches

Why do javascript sub-matches stop working when the g modifier is set? var text = 'test test test test'; var result = text.match(/t(e)(s)t/); // result: ["test", "e", "s"] the above works fine... [1] is e and [2] is s... perfect var result = text.match(/t(e)(s)t/g); // ["test", "test", "test", "test"] the above it screwed... it ig...

Retrieve mouse locations outside of an event handler

How can I retrieve the mouse location outside of it's assigned event handler function For example, if Event.MOUSEMOVE = somefuction, how do I say... someOtherFunction( maybeSomeParams ) { getCurrentMouseLocn(); } or someOtherFunction( maybeSomeParams ) { mouseXLocn = ?; mouseYLocn = ?; } ...

Server-side Javascript (aspx.cs) Attributes.Add Code to Change a Label's text

I am trying to change a label's text by using server-side javascript (onclick) and C# within the page_load event. For example, I would like to write something like the following: Label1.Attributes.Add("onclick", "Label2.text='new caption'") Does anyone know the correct code for this? Also, what is this type of code referred to; is it...

Google Geocode via HTTP callback function?

I want to use the google geocode via HTTP functionality to translate a city name into longitude and latitude in for my AJAX web application. However, it appears that no callback function exists for the HTTP geocoder functionality http://code.google.com/apis/maps/documentation/geocoding/index.html Is that true, no callback function exi...

How can I force the DOM to re-eval in Javascript/jQuery?

I am dynamically appending HTML to a webpage and I'm also using jQuery to manage stuff. When I add HTML code, jQuery ignores its existence. For example: $("td.elementToClick").click(... Will work great with jQuery. But if somewhere in the code I append: $("tr#myRowToAppend").append("<td class="elementToClick>...</td>"); jQuery wil...

Dependency Injection in XPCOM

Hi, One of my XPCOM components make use of other XPCOM components. As I was testing it, I found it cumbersome cos of the dependencies. Then I thought of using Dependency Injection to pass in the other components in my constructor. I wasn't successful. Is it possible to pass in references of other components into your constructor? var ...

Firefox 3 window focus and blur

Hello, $(window).blur(function(){ windowFocus = false; }).focus(function(){ windowFocus = true; }); The problem is that in firefox 3, when I create a new tab, it does not lose windowFocus. Where as in ff2, ie7 it does lose. In ff3 it only loses window focus when i select another program. Anyone have a solution to this problem? ...

accessing cookies, hopefully in javascript

I am working on a Firefox add-on that will allow users (all of whom are part of a specific group; this add-on is very limited in audience scope) to see the status of their authentication cookie from the status bar. We all have to authenticate to access work-related sites, but we get no warning when the cookie expires, so this causes anno...

Query URL for Log In Status, javascript

This may seem like a no-brainer, but I can't find a way to do this that isn't considered a security issue (other than the obvious ways)... So, I want to build an add-on for Firefox to use with my team. Basically it will be a status bar icon letting us know if the authentication cookie for our tools site has expired, so we can tell witho...

JQuery File extension rewrite, load new url into hidden div

I have a thumbnail gallery in a div on my sidebar. Each of these jpg images links to the larger jpg image in the main div of the same page. I have these loading in a div via fadein jquery with the following: $(function() { $('.vid-gallery-thumbnail a').click(function() { newImg = $(this).attr('href'); $('.ngg-imagebrowser img').fad...

Iterating through all the <div> tags on a page

I want to go through all the elements on a page using Javascript and see if they have a property set. Is there an easy way to do this, or do I have to use a recursive solution? ...

Is there a better way to get ClientID's into external JS files?

Hi, I know this has been asked before, but I've found a different way to get references to controls in external JS files but I'm not sure how this would go down in terms of overall speed. My code is public static void GenerateClientIDs(Page page, params WebControl[] controls) { StringBuilder script = new StringBuilder(); ...

jQuery-ui tabs character encoding problem

Swedish characters get substituted when setting the tabTemplate option. For example using "ö" in the href: var $tabs = $("#tabs").tabs('option', 'tabTemplate', '<li><a href="#ö">#{label}</a></li>'); becomes: <li><a href="#%C3%B6">ö</a></li> ...

Why is this code so slow?

jsc.tools.road.correctType = function() { for(row = jsc.data.selection.startX - 1; row <= jsc.data.selection.endX + 1; row++) { for(col = jsc.data.selection.startY - 1; col <= jsc.data.selection.endY + 1; col++) { if(jsc.data.cells[row-1][col].type != "road" && jsc.data.cells[row+1][col].type != "road" && jsc.data...