Hi! A few hours ago, I was instructed how to style a specific textarea with JS. The following piece of code (thanks again, Mario Menger) works like a charm in Firefox but unfortunately nothing happens in Internet Explorer (7 tested only so far).
var foo = document.getElementById('HCB_textarea');
var defaultText = 'Your message here';
foo.value = defaultText;
foo.style.color = '#888';
foo.onfocus = function(){
foo.style.color = '#000';
if ( foo.value == defaultText ) {
foo.value = '';
}
};
foo.onblur = function(){
foo.style.color = '#888';
if ( foo.value == '' ) {
foo.value = defaultText;
}
};
I've already tried to replace 'value' by 'innerHTML' (for IE only) but to no effect. Any suggestions? TIA
I would like to convert a floating point variable to a string without losing any precision.
I.e. I would like the string to have the same information as my floating point variable contains, since I use the output for further processing (even if it means that the string will be very long and readable).
To put this more clearly, I would like to have functions for cyclic conversion
var dA = 323423.23423423e4;
var sA = toString(dA);
var dnA = toDouble(sA);
and I would like dnA and dA to be equal
Thanks
PS: Sources on the internet usually talk about how to round strings but I have not found information on exact representation. Also I am not interested in Arbitrary Precision calculations, I just need double precision floating point arithmetic.
I need a way to turn my 2 character string dates (i.e. '04/10/2010' & '05/24/2010') into an integers in jquery to see if one is greater than the other. If the user enters an end date that is less than the begin date I need to popup an "invalid date range" error.
Hello,
I am designing a web site that plays music. The music player itself will be in a separate window along with the now playing list. I want to be able to refresh the now playing list when a new song is added to it from the main window. Essentially I need to figure out how to communicate between the two windows. I was only able to find one plugin on line that defines the player page as a child of the main page but then this reference would be lost after the parent page i.e my main page was refreshed. So this was not very useful to me and I'm kinda lost atm.
Any help is greatly appreciated
PS: here is the link to that plugin (http://www.sfpeter.com/2008/03/13/communication-between-browser-windows-with-jquery-my-new-plugin/)
I am storing a JSON string in the database that represents a set of properties. In the code behind, I export it and use it for some custom logic. Essentially, I am using it only as a storage mechanism. I understand XML is better suited for this but I read that JSON is faster and preferred.
Is it a good practice to use JSON if the intention is not to use the string on the client side?
I am using google maps api v3 and have an array of arrays object:
MVCArray.<MVCArray.<LatLng>>
I want to iterate over this. I see that MVCArray has a method forEach which uses a call back, but I have no idea how to use this (I haven't done much js). The api defines this method as follows:
forEach(callback:function(*, number)))
Could somebody please show me an example of how to use this given an MVCArray of MVCArrays?
I'm retrieving an array of objects from a hidden html input field. The string I'm getting is:
"{"id":"1234","name":"john smith","email":"[email protected]"},{"id":"4431","name":"marry doe","email":"[email protected]"}"
Now I need to pass this as an array of objects again. How do I convert this string into array of objects?
Hi, I'm using CurvyCorners to make my corners curvy in IE, only thing is that when it reads the CSS it takes all the webkit properties and shows me an alert curvyCorners.alert("No object with ID " + arg + " exists yet.\nCall curvyCorners(settings, obj) when it is created.");.
How can I just set this if statement to do nothing?
if (j === null)
do nothing(); //but in real script
Thanks :)
why does the following js expression:
"test1 foo bar test2".replace(/foo.bar/, "$'")
result in the following string?
"test1 test2 test2"
is the $' in the replace string some sort of control code for including everything after the match???
this behavior was screwing with me most of the day. can anyone explain this?
thanks a lot
ps- this is the case in all browsers i've tested
I have a very simple function that takes a list of comma separated (x,y) points and imports them into a graph. I have FF, Chrome and IE8 installed. I use IETester to test for IE6 and IE7.
// Import Data
this.Import = function(data) {
alert("Data in: "+data);
var d;
// Make sure the first and the last are start/ending parenthesis
if ( (data[0] != '(') || (data[data.length-1] != ')') ) {
alert("After if: "+data[0]+" "+data[data.length-1]);
return false;
}
...
In Chrome, FF and IE8, I don't see the "After if:" alert.
In IE6 and IE7, I see the following two alerts:
Data in: (52,16),(100,90)
After if: undefined undefined
The "Data in" alert matches in all browsers.
Any ideas?
I need a way to turn my 2 character string dates (i.e. '04/10/2010' & '05/24/2010') into an integers to see if one is greater than the other. If the user enters an end date that is less than the begin date I need to popup an "invalid date range" error.
I was adding recent videos gadget on my blog. In that widget i was supposed to add this line
<script src="/feeds/posts/default?orderby=published&alt=json-in-script&callback=showrecentpostswiththumbs">
also, i added another script which was having the method showrecentpostswiththumbs [ used in callback ]. Please let me know what does above syntax do?
Hi this is my pice of code:
<div style="overflow: hidden; width: 445px;">[IMG]http://i29.tinypic.com/mydog.png[/IMG] tak si to http://i29.tinypic.com/mycat.png Lorem ipsum loremai <img width="15" border="0" align="middle" src="images/smejo.gif" valign="middle"/> <img src=http://www.example.com/index.png alt> <img src="http://www.example.com/index.png" alt> <a href="#reakcia" title="reagovat na temu"><span class="poradna-tl-reaguj"><reaction> </span></a></div>
</td> </tr><img src=http://www.example.com/index.png alt><img src="http://www.example.com/index.png" alt>
and i need regex pattern to replace ONLY text image links with image without touch of inner url tags.
But i can't use "Lookbehind" or possessive quantifiers because JS don't support them=/
So i want to catch only "http://i29.tinypic.com/mydog.png" and "http://i29.tinypic.com/mycat.png".
I using array method to replacing (will be greasemonkey script.)
Many Thanks
I'm trying to understand if I can debug a stand alone .js file which doesn't interact with browser. Is there any way to just load it and debug or I will be forced to encapsulate it into html file?
I'm working on a project here that will store some info in Google Analytics custom variables. The script I'm building out needs to detect if GA has loaded yet before I can push data to it. The project is being designed to work across any kind of site that uses GA. The problem is reliably detecting if GA has finished loading or not and is available.
A couple of variabilities here:
1) There's multiple methods of loading GA. Older scripts from the Urchin days up to the latest asynchronous scripts. Some of these are inline, some are asynchronous. Also, some sites do custom methods of loading GA, like at my job. We use YUI getScript to load it.
2) Variable-variable names. In some scripts, the variable name assigned to GA is "pageTracker". In others, its "_gaq". Then there's the infinity of custom variable names that sites could be using for their implementation of GA.
So does anyone have any thoughts on what might be a reliable way to check if Google Analytics is being used on the page, and if it's been loaded?
I'm working on a simple subtraction problem, but unfortunately it keeps returning NaN
Here is the function
function subtraction(a, b) {
var regexp = /[$][,]/g;
a = a.replace(regexp, "");
b - b.replace(regexp, "");
var _a = parseFloat(a);
var _b = parseFloat(b);
return _a - _b;
}
And here is how I'm calling it.
txtGoodWill.value = subtraction(txtSellingPrice.value, txtBalanceSheet.value);
The numbers that get submitted to the function are ONLY Currency (IE: $2,000 or $20, etc)
Now I know that I cannot subtract numbers with a $ or a ,, but I can't for the life of me figure out why they are getting evaluated in the equasion.
Hi, I am trying to optimize my program. I think I understand the basics of closure. I am confused about the scope chain though.
I know that in general you want a low scope (to access variables quickly).
Say I have the following object:
var my_object = (function(){
//private variables
var a_private = 0;
return{ //public
//public variables
a_public : 1,
//public methods
some_public : function(){
debugger;
alert(this.a_public);
alert(a_private);
};
};
})();
My understanding is that if I am in the some_public method I can access the private variables faster than the public ones. Is this correct?
My confusion comes with the scope level of this.
When the code is stopped at debugger, firebug shows the public variable inside the this keyword. The this word is not inside a scope level.
How fast is accessing this? Right now I am storing any this.properties as another local variable to avoid accessing it multiple times.
Thanks very much!
Is there a better way other than looping to find data in JSON? It's for edit and delete.
for(var k in objJsonResp) {
if (objJsonResp[k].txtId == id) {
if (action == 'delete') {
objJsonResp.splice(k,1);
} else {
objJsonResp[k] = newVal;
}
break;
}
}
The data is arranged as list of maps.
Like:
[{id:value, pId:value, cId:value,...}, {id:value, pId:value, cId:value}, ...]
Hello,
Is this the notation to use for Not Equal To in JS, in jquery code
!== OR !=
None of them work
Here is the code I am using
var val = $('#xxx').val();
if (val!='') {
alert("jello");
}
Thanks
Jean