javascript

How to determine whether click happened on element's scrollbar or on its content

There is indeed method element.componentFromPoint(iCoordX, iCoordY) in Internet Explorer, but how do I differentiate a mouse click occurred in the content area of an element from the click occurred on its scrollbar in other browsers? ...

What is the significance of the Type parameter in the RegisterClientScriptBlock method call?

Hi, This is an example of RegisterClientScriptBlock Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "key","scriptblock", True) Why do the method needs the type as the first parameter ? Thanks. ...

Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser

I want to handle F1-F12 keys using JavaScript and jQuery. I am not sure what pitfalls there are to avoid, and I am not currently able to test implementations in any other browsers than Internet Explorer 8, Google Chrome and Mozilla FireFox 3. Any suggestions to a full cross-browser solution? Something like a well-tested jQuery library ...

Compression issues with JQuery file in YUI Compressor

I am trying to minify a few files with YUI compressor. However, I seem to be getting an error on 2 lines of code, which prevents compression. The .js file for jcarouselLite contains 1 error, and my own code contains the other. I have narrowed it down and in both occasions it looks like the the float property used in jQuery is causing t...

Not allowing javascript function call from the address bar

I was working with a online game website. There are some event which call a javascript function and the function have some action with callback. something like this, <input type="button" onclick="changeSomething"/> function changeSomething() { /// some call back, which changes something } now anybody who knows this c...

Converting letters to their greek equivalent in Javascript

I have some JSON data from a web service which gives me data like the following blah blah <greek>a</greek> I need to be able to convert what is inside the greek tags into their symbol equivalent, using javascript. Any ideas? ...

Does jQuery have a built in function to return the rootURL?

I typically use the below function to return the root URL if I ever need this, but thought to ask if jQuery had a "one liner" way to do this ... function getRootURL() { var baseURL = location.href; var rootURL = baseURL.substring(0, baseURL.indexOf('/', 7)); // if the root url is localhost, d...

String.replace; replace by function result problem

Hi, I have this piece of code: var myObj = function () { this.complex = function (text) { /* long piece of code */ } this.parse(text) { return text.replace(/valid_pattern/gi, function ($1) { return this.complex($1); } ); } } Of course calling this.complex($1) won't do the trick, because I'm in the scope of the anonymous...

Returned AJAX html breaks IE click events

I have a table of paged data, along with a dynamically created pager (server-side AJAX call, apply returned HTML to the innerHTML of a div). When I click next page on my pager, an AJAX call is sent to the server to retrieve the next set of data, which is returned as a string of HTML. I parse the HTML and render the new table rows. I als...

How would you reverse engineer this?

I've got some code that was at the bottom of a php file that is in javascript. It goes through lots of weird contortions like converting hex to ascii then doing regex replacements, executing code and so on... Is there any way to find out what it's executing before it actually does it? The code is here: http://pastebin.ca/1303597 G-M...

How to add node into TreeView Control with Javascript

Hi guys, I just wanna learn how to add a node to TreeView control (which takes its data from database with a parent-child relationship). Of course when I select a node the new node I wanna add should be added under the selected one and after adding it into the selected node then I wanna add the new node into database too. I can handle t...

Howto create a jquery-like $() wrapper function?

I'm creating a small code plugin which allows you to do some things with arrays. I do not wish to add the functions to the array object using a prototype construction, what I want is that people can do something like: arrayFunction( [1, 2, 3] ).someSpecialArrayFunction(); Thus leaving the normal array object unaltered. So I came up wi...

Javascript: How to dynamically create an <option> that contains an HTML entity (— ... «)

I'd like to add an <option> element to a <select> element where the <option> element's text contains an HTML entity: &mdash; In HTML, the code would look like this: <select name="test" id="test"> <option value="">&mdash; Select One &mdash;</option> </select> My Javascript code looks like this: function selectOne() { var e = docume...

Prevent line/paragraph breaks in contentEditable

When using contentEditable in Mozilla, is there a way to prevent the user from inserting paragraph or line breaks by pressing enter or shift+enter? ...

Javascript/xhtml - discovering the total width of content in div with overflow:hidden

I'm writing a javascript based photo gallery with a horizontally scrollable thumbnail bar. >> My current work in progress is here << I would like the thumbnail bar to stop scrolling when it gets to the last thumbnail. To do this I need to find the total width of the contents of the div - preferably without adding up the widths of all t...

Is there a way to request permission in IE to use window.external.AddFavorite?

The JavaScript security settings on Internet Explorer for my customers disallow using window.external.AddFavorite, and it generates (best case) an error in the status bar when the users click the "Add Bookmark" link on my website. Is there a way to explicitly request permission to use the window.external.AddFavorite method from the user...

clearTimeout on multiple setTimeout

Hi everyone, I have multiple setTimeout functions like this: function bigtomedium(visiblespan) { visiblespan.removeClass('big').addClass('medium'); setTimeout(function(){ mediumtosmall(visiblespan);},150); }; function mediumtosmall(visiblespan) { visiblespan.removeClass('medium').addClass('small'); setTimeout(function() { s...

Extend Javascript Function passed as parameter

I have a javascript function (class) that takes a function reference as one paremter. function MyClass ( callBack ) { if (typeof callBack !== 'function') throw "You didn't pass me a function!" } For reasons I won't go in to here, I need to append something to the function by enclosing it in an anonymous function, but the only wa...

jquery plugin for preventing entering any input not matching a regexp

does jquery have any plugin that prevents entering any input to a textbox that doesnt match a regexp pattern. for example , i have a textbox for entering payment amount, i want user t be able to enter only numebers and . in the textbox, all other input wont have any effect on the textbox.. thanks ...

Executing groovy statements in JavaScript sources in Grails

There are essentially 2 places to define JavaScript functions in Grails, directly in a element on the GSP, and within a separate javascript source file under /web-app/js (for example, application.js). We have defined a commonly reused javascript function within application.js, but we also need to be able to generate parts of the functio...