javascript

Dynamically loading css stylesheet doesn't work on IE

Hi, I dynamically load a css stylesheet (with a little help from jQuery) like this: var head = document.getElementsByTagName('head')[0]; $(document.createElement('link')) .attr({ type: 'text/css', href: '../../mz/mz.css', rel: 'stylesheet' }) .appendTo(head); This works fine in Firefox and Google Chrome, but not in IE. Any h...

JQuery event.stopPropagation() not working

Hi all, In my html I have a span of class dragHandle embedded within a li. <div class='treeView'> <ul class='tree'> <li><span class="dragHandle"></span>Item 1 <ul> <li><span class="dragHandle"></span>Item 2 <a href="#">link</a></li> </ul> </li> </ul> I attach event handlers using jQuery as follows: ...

Help with regexp to extract values from inside brackets

I would like to get a regexp that will extract out the following. I have a regexp to validate it (I pieced it together, so it may not be the the best or most efficient). some.text_here:[12,34],[56,78] The portion before the colon can include a period or underline. The bracketed numbers after the colon are coordinates [x1,y1],[x2,y2].....

How can I get older jquery code to work with newer versions of jquery?

Related: http://stackoverflow.com/questions/528241/how-do-i-run-different-versions-of-jquery-on-the-same-page/528251 I have a pages that uses a lot of jquery, I have a drag and drop that saves position into mysql DB also. My jquery file is about 2 years old and today I tried to use a newer version because there is a script I am wanti...

How to determine a 'line-height' using Javascript (jQuery)?

Well, encountered the need of a line-height coding a plugin, so, can you give an advice, please? Thanks) ...

Is an autocomplete text box for entering addresses a good idea?

Entering my address via a traditional form drives me crazy: Why do I have to enter my city, state, and zip code when my city and state can be inferred from my zip code? Choosing your state from a dropdown list is a pain in the ass -- often you can't tab into it, you have to use the mouse, etc. Because I find this process so repulsi...

Add onLoad function for to an opened window

How to add an onLoad function to an opened window? (target is "self", not window.open, just a regular link) Is it possible with onbeforeunload or something? Or add onclick to the "normal link"? I mean like this: <a href="page2.htm" onclick="theWindowIHaveOpened.onLoad = function(){alert('loaded')}">... ...

Open URL from within a javascript-based Adobe AIR app

I've got an adobe AIR application that is written entirely in HTML/Javascript (no Flash). It's mostly self-contained but there's a single link that is meant to open a url in the user's default browser. Instead, it opens it in a separate AIR browser window. How can I go about forcing AIR to open the link in the user's default browser? ...

Regex Allowing for Hours in 15 Minute Increments

I need a regex which restricts an hour entry from 0-24 with the fraction in multiples of .25. Please keep in mind the following conditions must be met: When whole part is 0-23, the fractional part can be .0, .25, .5, or .75 When whole part is 24, the fractional part can be .0 When no whole part is present, the fractional part must be ...

SVG Parser in Javascript

I believe that at one point, I saw a TinySVG implementation that worked in the browser, using the canvas element as the backend. I found a few sites that appeared to indicate it was at http://fuchsia-design.com/CanvaSVG/, however, that site appears to no longer exist. Is this project (or a similar one) still on the web anywhere? ...

Event handler does not apply to created element

Well, the title may not make any sense at all.. But anyway, I ma put some easy codes to clarify it. I am using JQuery 1.3.2 Here is my JS $(document).ready(function() { $('#test').click(function() { $('#result').html('<a href="#" id="hello">hello world</a>'); }); $('#hello').click(function() { $('#result').html('<a href...

How to get subset of string using Javascript/JQuery/JSON?

Hi, I want to get a subset of a string in Javascript. Currently, I only know how to store the entire string: I have this as a JSON variable with a callback to foo: foo({"results":[ "<div id=\"following\"><span><a href=\"http://twitter.com/barackobama\"&gt;Obama&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;" ]}) And this is my callback function:...

JavaScript keydown error in IE

<script> var personX = 18; var personY = 13; function processArrowKeys(E) { if (E.keyCode == 37 || E.keyCode == 38 || E.keyCode == 39 || E.keyCode==40) { E.preventDefault(); } if (E.keyCode == 37) { if (currentterrain[personX - 1][personY] == 0 || currentterrain[personX - 1][personY] == 1 || currentterrain[p...

Call a Javascript function within an inline statement

Hey all, Quick question: It's kind of tough to describe so let me just show an example. Is there anyway to do this: (I'm using jQuery but this is a general javascript question) $('div.element').offset().x; $('div.element').offset() by itself will return {'x' : 30, 'y' : 180}, so I'm just wondering if there is any compact way of doing...

Hide Image Title in Slimbox

My issue is a lot like this solved thread, except I'm using Slimbox 2: http://stackoverflow.com/questions/940994/hide-image-title-tool-tip-popup-on-mouse-rollover-or-hover When you hover over an image, the "Title" attribute pops up. I need HTML in my image title in Slimbox. So, of course, when you're hovering, the "Title" attribute sho...

JavaScript Regex Ignore Case

Hi, I am trying to match a part of the string and it should be NOT case sensitive. I have the following code but I never get the replaced string. var name = 'Mohammad Azam' var result = name.replace('/' + searchText + '/gi', "<b>" + searchText + "</b>"); The searchText variable will be "moha" or "mo" or "moh". How can I get the m...

jQuery can't parse JSON built with Ruby-JSON

I'm trying to set up an Ajax callback using jQuery, and it's just not working. My Ruby code looks something like this: return {:one => some_html, :two => more_html}.to_json When it gets to the client jQuery bails saying "parse error". If I make it something really simple, like: return {:one => 'Something', :two => 'Something else'}.t...

How do I match a whole sentence in Javascript Regular Expressions?

I need to create a Regular Expression (in Javascript) that will match a specific sentence structure. In my case, it's "Course ### day ###", where ### can be any 1 to 3 digit number. Additionally, it can be "week" instead of "day", so "Course ### week ###" is also valid. So far, I've come up with: var regTest=/^(Course) \d{1,3} (day)|...

how to invoke a dynamically loaded javascript function

I was implementing a on-demand script controller based on jquery's getscript, it looks like this: function controller = function(){ var script = function(){ var scripts = {}; return { load: function(jsurl){ $.getScript(jsurl, null); }, run: function(js){ window[js].apply(this,n...

How is this working ??

I was browsing through one site called BSEINDIA.com (http://www.bseindia.com/stockreach/stockreach.htm?scripcd=532667), i Noticed that on click of Get Quote it seems to fire an Ajax request and get the price of selected equities. I tried to segregate this request and fire it separately, but it doesn't seem to work. I copied over the cod...