javascript

How do I implement this regular expression in Javascript?

How do I make a Javascript regular expression that will take this string (named url_string): http://localhost:3000/new_note?date1=01-01-2010&date2=03-03-2010 and return it, but with the value of the date1 parameter set to a new date variable, which is called new_date_1? ...

empty value of option's element

Hi! I have a similar problem like old problem of mine. my code: function reset_admin() { a = document.getElementById('event').value; t = document.getElementById('category').value; document.getElementById('admin').reset(); document.getElementById('event').value = a; document.getElementById('category').value = t; } ...

Detect changes on disabled field

It seems propertychange events are ignored when a field is disabled. Is there a way to run code when the value changes? <input id="country" onpropertychange="alert(country.value)" disabled="disabled"/> <input type="button" onclick="country.value='USA'" value="Go" /> ...

How to focus main web page after opening a new window?

I want to be able to focus the original page after opening a new window/tab, the same way as it's done on this website: http://www.vouchercodes.co.uk/laredoute.co.uk ...

Should I care about private members in JavaScript

Hi, I know that JavaScript doesn't support private members, but you can emulate those. I'm wondering here is that if it's worth it. Is there a point in making variables and/or functions private in JavaScript? ...

Running code on page loaded?

Hi, I have a MVC view that contains some dropdowns like this : <%: Html.DropDownListFor(model => model.CS.C1, Model.CS.Category1List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.CS.C2, Model.CS.Category2List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.CS.C3, Model.CS.C...

Why wont this js code work in Chrome and Safari?

I have an iframe on my index.html and this iframe is dynamic. on my index.html I have a form, which when submitted, shows the results inside the iframe. The problem is the Iframes height also has to be dynamic for the website to look "clean". So in the Iframes php page, I have this code: <body onload="parent.resize_iframe(document.bo...

changing form post

I want to change form post data before send. i use some java script code to get some user inputs and want to attach those to request post data. I wanna a normal post that cause to display result as a an HTML page. its may be useful that i linked JQuery and can use its functions. Thanks very much! ...

Can't figure out why Chrome/Safari can't get the ScrollHeight right here

I just asked a question about why a certain js code won't work in Chrome and Safari 100%, but after more troubleshooting I think I have found out that this is the question I should be posting. I have a page which has a form in it. This form's target is an iframe on the same page. The iframe is dynamic, and php based. This is the bottom...

Some really good examples of well written javascript

Can anyone point me in the direction of some really well written javascript examples. I have been trying to improve my javascript after reading a lot from douglas crockford book etc but i wondered where i could find some live examples of code that is written well? ...

How does facebook rewrite the source URL of a page in the browser address bar?

Go to http://www.facebook.com/facebook?v=wall, then click on the info tab. The content will be loaded, and the address bar now becomes http://www.facebook.com/facebook?v=info but the webpage didn't reload. At first I think it is Ajax, but my question is, how do you change the address bar without reloading? I know I can change anchor (#w...

javascript constructs to avoid?

I have been writing a JS algorithm. Its blazing fast in chrome and dog slow in FF. In the chrome profiler, I spend <10% in a method, in FF the same method is 30% of the execution time. Are there javascript constructs to avoid because they are really slow in one browser or another? One thing I have noticed is that things like simple v...

How can I execute a javascript in webview of BlackBerry

Hi All, I want to execute a JavaScript code automatically after loading a website through WebView of BlackBerry. I'm using OS 5 for that. But can't find a way out. Thanks in advance. ...

Can not call JavaScript within Java program

My test case is based on the sample in the article link text As I run the main function in ScriptDemo.class, I got the follwoing error: This error locates on engine.eval(scriptReader, vars); java.lang.IllegalStateException: FAILED ASSERTION at sun.org.mozilla.javascript.internal.Kit.codeBug(Kit.java:466) at sun.org.mozilla.javascript....

canvas drawImage doesn't draw images the first time

I'm working on a simple JavaScript game using HTML5 canvas. It's a very typical game-loop setup involving: init() function that initializes objects to be used the playfield, randomizing some start x/y positions and similar setup tasks draw() function that draws all the game objects, including some simple canvas shapes and a few images ...

Google Maps API, without Login

I have google maps api on my application and I would like to create new maps on google map from my application. I know that this can be done, but you have to login and than data is send to you account. What I would like to do is to send data to just one accout, so that my users will not need to sign in to google. ...

jQuery: Grouping Similar Items

Using jQuery, I'm trying to group similar items in a list. Here's what I'm trying to do. Given a list like the following: <ul> <li class="foo">Item #1</li> <li class="foo">Item #2</li> <li class="foo">Item #3</li> <li class="bar">Item #4</li> <li class="bar">Item #5</li> <li class="foo">Item #6</li> <li class...

Differentiating rows' elements in Prototype

Hi, I have a table that contains in each row an input and a "save" image. <td> <div id="acp_1" style="margin-left:100px;display: inline"> <input size="10" type="text" value="11:00" name="acpr_1" id="acpr_1" /> <span class="modify-listener" id="ml_1"> <img id="save_1" src="/images/skin/database_save.png" alt="modify"/> </s...

How to prevent browser's default history back action for backspace button with JavaScript?

Hi, Is there a way to prevent the default action from occurring when the user presses backspace on a browser? I don't need to prevent the user from leaving, just from having the default backspace action. I need the backspace to do something different (it's a game). I tried without success: window.addEventListener('keydown', function(e...

How to respond to mouse button clicks in Javascript?

I want to be able to write code to respond (seperately) to the following events: Right hand click Left hand click Middle button click (optional - nice to have but I can live without this). Is there an inbuilt way in Javascript that I can respond to these events, or do I need to use a library (preferably jQuery) ? ...