javascript

javascript: how to include file depending on subdirectory

Hi everyone, I need your help. I need to include external files (menu) on a template depending on the current sub directory. For ie; I have two sub directories: http://subdomain.domain.com/xx/index.html http://subdomain.domain.com/yy/index.html and each sub directory has own menu file. How to create this conditional script on JavaSc...

JavaScript Switch Statement Fades Opacity to None But Doesn't Fade it Back

Hey all, I have a really weird situation. The idea is there is a scroller that moves from left to right to display different groups. But when it stops to show specific group, there are links to leaf through different "pages" of the group. Now in order to do this, you click link one page fades and another fades in. Everything worked smoo...

Why doesn't this JavaScript work in IE8?

<form action="http://google.com"&gt; <input type="submit" onclick="javascript:this.disabled='disabled';return true"> </form> It works in Firefox, but not in IE8, Safari (It should forward me to Google's site, it but doesn't happen.). Why? ...

how to create an utf8 string in Google V8 engine

Hello Im using v8 engine embedded in C++ program and I met a string problem. Well of course v8 engine fully support utf8 string, but i just dont know how. char path[ 1024 ]; GetCurrentDirectory( 1024, (LPWSTR)path ); script->Path = String::New(path); However, the result is the only character "D", for String::New only accepts char*...

JavaScript, Generate a Random Number that is 9 numbers in length

I'm looking for an efficient, elegant way to generate a JavaScript variable that is 9 digits in length: Example: 323760488 ...

How can i define my own event in jQuery?

How can i define my own event in jQuery? ...

Ignoring whitespace immediately before a character in RegEx

As an exercise in learning RegEx in JavaScript, I've been trying to select an attribute's value within a CSS stylesheet. Given the following CSS: foo { color: rgb(0, 0, 0) !important; background-color: rgb(0, 0, 0) !important; border-left: 1px solid #111; } and a function getStyle(css, attribute) such that getStyle(css, 'b...

YUI compressor added "get " string

Yuicompressor is adding a "get " string onto my javascript minified files ie: }get ,getExecuteProcessUrl:function(){var a=ERDAS.misc.getTilapiaBaseUrl()+"/executeW.do";return a}get ,cbRunStartSuccess:function(a,b){var c={interval:this.DEFAULT_INTERVAL};b.setStatus(a);b.cbSuccess(a); what is causing this? and how can I fix this? ...

Why does assigning a value to an array in a for loop result in the array having the same value for each iteration when passed to console.log()?

Given the following code: var tmp = [0]; for(var i=0;i<100;i++) { tmp[0] = i; console.log(tmp); } I'd expect output of [0], [1], [2], [3], etc But I instead get [99], [99], [99], [99], etc Stepping through the code in a debugger (firebug) however nets me the correct result of [0], [1], [2]. ...

Using jQuery to check for regular expressions

Hi all, I know there's the jQuery validation plugin. But I don't need something that extensive. All I want to do is have jQuery check a name text box: <input type="text" name="name" id="name" /> To make sure that it has at least 2 characters AND I want jQuery to check a phone text box (identical to the name text box, name="phone" ...

Looking for JS that shows/hides images in div (see example in description)

http://www.ppowgallery.com/artists.php has an example of what I want. I want to load a bunch of images and have them appear when you roll over an item in a list or another text link. Can somebody direct me to a good example? I don't even know what you'd call this effect. Thanks! ...

Best way to add page specific javascript in a Rails 3 app?

Rails 3 has some unobtrusive javascript which is pretty cool. But I was wondering what the best way is to include additional JS for a particular page. For example, where I might have previously done: <%= f.radio_button :rating, 'positive', :onclick => "$('some_div).show();" %> We can now make it unobtrusive with something like <%= ...

javascript settimeout cleartimeout routine syntax

Hi, This is the code from another thread. It activates a function only when the user has stopped typing after a set time. var keyupTimer; function keyUpEvent(){ clearTimeout(keyupTimer); keyupTimer = setTimeout(sendInput,1000); // will activate when the user has stopped typing for 1 second } function sendInput(){ alert("Do...

Setting java string variables value depending on html checkbox selected

Hi I have two check boxes with table names when any check box is checked i wants to save that table name in to a java string which i can use in the query to get data from that table or update that table. I have used onClick functions and also got the check box value but not getting how to access it in the rest of the code so that i can ...

Can we connect database with javascript

Is it possible to connect database with javascript. ...

how to replace multiple occurrences of `&nbsp; and <br>`

how to replace multiple occurrences of &nbsp; and <br> at start of the string with javascript regex? ...

Javascript validation Problem

In my employee information page, i use the validation in the information page. In that javascript regular expression, var nameRegex = /^[(a-z)(A-Z)\s ]*$/; This nameRegex match with my last and firstname. } else if(!lastname.match(nameRegex)) { For this one, special character are not allowed in last name. It restrict all the spec...

Using regex to potentially improve performance of string parsing?

Hi, I have a string like this: // string1 horse|cow|goat|zebra| and another string like this: // string2 horse:a,pig:b,cow:z,monkey:g,goat:a, my goal is to split string1, then pick out any occurrences of it in string2, to build a histogram. I am currently doing this: var histogram = {}; var animals = string1.split("|"); for (var...

how to get web page size, browser window size, screen size in a cross-browser way?

how to get windowWidth, windowHeight, pageWidth, pageHeight, screenWidth, screenHeight, pageX, pageY, screenX, screenY in IE/FireFox/Chrome/Opera? or jquery, GWT? as showed in picture above! thanks! ...

render :partial generates only one time on escape_javascript

render :partial generates only one time on escape_javascript eg <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $("#addPerson").click(function(){ $("#user tr:last ").after("<%= escape_javascript(render :partial => 'user_item', :locals =>{:user_item => User.new}) %>"); ...