JQuery :: Css() Function Returns Different Results On Different Browsers?
Jun 11, 2009
Today I've tried to create simple hover effect on a <div>: if the cursor is over the box, the background-image css property of the div is modified. On the HTML side, a <div> with an id:
<div id="round">Blah blah
</div>
View 3 Replies
ADVERTISEMENT
Jun 29, 2010
If you call the below code, it will incorrectly print "true, false" when it should be "true, true". WHy is that? How do I fix this?
Code: isCapitalLetter = /[A-Z]/g;
//Incorrectly alerts "true,true"
alert( isCapitalLetter.test( "lineHeight" ) + "," + isCapitalLetter.test( "lineHeight" ) );
View 3 Replies
View Related
Aug 15, 2009
I'm new to ajax. I've made a script that should return results from database but it keeps telling me just undefined. Code what I have:
Code:
var ajax = null;
function showRes(wut) {
if(wut.length == 0) {
document.getElementById("results").innerHTML = "";
return;
} if(window.XMLHttpRequest) {
// IE7+, ff, chrome, opera, safari
ajax = new XMLHttpRequest();
}else if(window.ActiveXObject) {
// retards
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert("Your "browser" does not support AJAX!");
return;
} var url = "search.php?q=" + wut;
url = url + "&sid=" + Math.random();
ajax.open("GET", url, true);
ajax.send(null);
document.getElementById("results").innerHTML = ajax.reponseText;
}
View 6 Replies
View Related
Aug 29, 2011
I am having a strange problem with a javascript function that does not return the value but returns the code inside the function. My best guess is that I am incorrectly calling the function hasLandedOn()and jquery is interpeting it. Why is this happening? I highlighted the parts in red.-Tom ReeseThe following is returned NOT the variable imageName.
function hasLandedOn(){
var selectorLoc = $("#selector").offset();
var imageName = "";
[code]....
View 2 Replies
View Related
Nov 23, 2010
In Firebug when I rollover the SelectList variable it certainly looks like an array.
[Code]...
View 2 Replies
View Related
Oct 8, 2009
Either I'm having a really dim Friday, or something strange is going on. I'm trying to add a method to the Validator plugin, using the following regex:
[Code]....
View 1 Replies
View Related
Nov 22, 2011
I am trying to make a function that will return part of some xml data, but It keeps returning "Undefined" here is the function, with the call:
Code:
function getUserInfo(u, t) {
$.ajax({
type: 'GET',
[code]....
View 6 Replies
View Related
Feb 15, 2012
I want to call java function in javascript.In which we pass one parameter to function and its returns String value which I want to display in alert message.
View 2 Replies
View Related
Dec 2, 2010
I have a for loop which has a length of 8. It's meant to run through an array of objects and bind a click function to all of them. So the alert should run a range 0-7 but instead it returns 8 no matter which object is being clicked.
for (var j = 0; j < bubbleArray.length; j++) {
$('#icon' + j).bind('click',function() {
var icon = this.id;
this.diam = $(this).width();
[Code].....
View 3 Replies
View Related
Sep 27, 2010
The goal is to change the source on the fly (as with a firefox extension webdev or another or even Greasemonkey) to add a link. Until then, easy does it work well. This link launches an application ajax jquery like:
$.get(...) or even $.ajax(...)
If I'm on [URL], added my link, I click and it works, I see the ajax request and pass my "alert ()" gives me the return of application. Great! But if I'm on a site other than mine (the url of the ajax request is [URL] while I'm at [URL] for example), the return of the ajax request is empty.
View 9 Replies
View Related
Jun 29, 2011
Clearly I am invoking this wrong.
[Code]...
View 1 Replies
View Related
Apr 15, 2010
I'm using JSON/jQuery to pre populate a drop down menu. What I want to do, is once I select a plan from the drop down menu and click submit (go button), to get the details about the plan. The drop down menu get's pre populated, but I don't get anything after clicking go. I check the functions and it seems that in the DoPlanSearch() I get the alerts showing the newly constructed URL that gets me the correct JSON. But not sure what happens once the data is processed after that. I say this, because my alert statement in the DoPlanSearchCompleted(data) gets me NULL data.
I'm just getting started with this, I'm not exactly sure what's the best approach. Also, I'm not sure the way .JSON files is setup here works, it does on my Dev server though.
Code has line: function DoPlanSearchCompleted(data)
It should read function UserPlanSearchCompleted(data). The same problem though exists.
View 1 Replies
View Related
May 18, 2011
I'm trying to pass an object to a function and not getting the results I need. If I get a reference to the object and pass it like so
[Code]...
View 1 Replies
View Related
Oct 6, 2010
I have this ajax function that executes till some output is done, but it doesn't work in some browsers like ie 6 or 7, if it is bad constructed:
View 4 Replies
View Related
Aug 25, 2009
JQuery and have a problem with an expandable menu I have created for a new Wordpress theme.
With my expandable menu I am simply (slide)toggling the children <ul> by clicking the parent <li>. This should work fine but jQuery is overiding the default event for the anchors in the children resulting in me having a nice expandable menu that animates well but with its links disabled.
As far as I can tell this should work as I am targeting one level of anchor beneath the parent and not any other more deeply nested children.
The problem only applies to the followning browsers - Firefox 3.5, Safari 4, Chrome and ie 8.
It works fine in ie 6 and 7, Firefox 3 and Opera 9.
The jQuery is as follows:
The html structure is as follows:
I left the anchor details (href, title and so on) out just to make the html code a little easier to scan.
View 1 Replies
View Related
Sep 26, 2009
Why this code is not working on Webkit browsers:
Only jquery and the plugin printed above are loaded, so there shouldn't be any conflicts.
HTML:
Chrome gives the following error: Uncaught TypeError: Object #<an Object> has no method 'followUser
View 10 Replies
View Related
Apr 23, 2010
Got a problem with the $.get() function on my site..
[Code].....
tunchecked is a checkbox that should call a php function called finishtask. the reload and preventdefault works but not the actual calling of the function.. it works in IE (8), Opera (10.5) but not in Chrome, Firefox(latest) or Safari.
View 3 Replies
View Related
Feb 21, 2010
I am trying to taking this embedded script
Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var strDay;
if ((now.getDate() == 1) || (now.getDate() != 11) && (now.getDate() % 10 == 1)) // Correction for 11th and 1st/21st/31st
strDay = "st ";
else if ((now.getDate() == 2) || (now.getDate() != 12) && (now.getDate() % 10 == 2)) // Correction for 12th and 2nd/22nd/32nd
strDay = "nd ";
else if ((now.getDate() == 3) || (now.getDate() != 13) && (now.getDate() % 10 == 3)) // Correction for 13th and 3rd/23rd/33rd
strDay = "rd ";
else
strDay = "th ";
document.write(dayName[now.getDay()] .....
// End -->
</script>
and turn it into a function called time.
XHTML Source
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "[URL]">
<html xmlns="[URL]" xml:lang="en">
<head>
<title>Test</title>
</head>
<body>
<strong><script type="text/javascript">time()</script></strong>
</body>
</html>
Javascript Source
Code:
function time() {
var strDay;
if ((now.getDate() == 1) || (now.getDate() != 11) && (now.getDate() % 10 == 1)) // Correction for 11th and 1st/21st/31st
strDay = "st ";
else if ((now.getDate() == 2) || (now.getDate() != 12) && (now.getDate() % 10 == 2)) // Correction for 12th and 2nd/22nd/32nd
strDay = "nd "; .....
But when I do the out put returns nothing. Why this might be. I initially thought that I had the formattingsyntax wrong for the function it self but this doesn't seem to be. [URL]
View 7 Replies
View Related
Sep 4, 2010
I have four images:
Code:
<div class="main_view">
<div class="window">
<div class="image_reel">
<a href="#"><img src="images/1.png" alt="" /></a>
<a href="#"><img src="images/2.png" alt="" /></a>
<a href="#"><img src="images/3.png" alt="" /></a>
<a href="#"><img src="images/4.png" alt="" /></a>
</div></div>
When rotateSwitch() is called on launch, it assigns the second image to the $active variable (given that the first image was given active class in beginning of script). Then rotate() function is called and we get 1 (2-1) and then multiply by imageWidth. Now the second time the rotateSwitch() function is called, we should get 2 (3-1), but the alert still only returns 1 and the fourth time it only returns 1 as well:
Code:
$(document).ready(function(){
$(".paging").show();
$(".image_reel img:first").addClass('active');
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;
$(".image_reel").css({'width' : imageReelWidth});
rotate = function(){
var triggerId = $active.attr('src').substring(7,8);
var image_reelPosition = (triggerId - 1) * imageWidth;
alert('the value is ' + triggerId);
$(".image_reel img").removeClass("active");
$active.addClass("active");
$(".image_reel").animate({
left: -image_reelPosition
}, 500);
};
rotateSwitch = function(){
play = setInterval(function(){
$active = $(".image_reel img.active").next();
if ($active.length === 0){
$active = $('.image_reel img:first');
}
rotate();
}, 7000);
};
rotateSwitch();
});
View 2 Replies
View Related
Dec 12, 2011
Suppose we have following javascript codes: Case 1.
var foo = function (){
var x = "hello";
var bar = function () {
alert(x);
} return bar;
} var bar_ref= foo();
document.write(bar_ref()); // it pops up "hello" and print-outs "undefined".
If we modified above code slightly, shown as follow: Case 2.
var foo = function (){
var x = "hello";
var bar = function () {
alert(x);
} return bar();
} var bar_ref= foo();
document.write(bar_ref()); // it only pops up "hello".
As you can see, Case 2 modified the return value from "return bar" to "return bar()," which won't cause the "undefined" output. To me, it looks like when the JS interpreter executes the line "bar_ref();" it triggers the execution of function "foo", besides both "return bar" and "return bar()" do the same job which is to execute function body of "bar".
The only difference is that after the execution of function bar, its function body does not exist anymore, so when the interpreter executes the line "return bar;" it follows the function identifier "bar" and ends up with "undefined". This is why the Case 1 gives us "undefined", but I am not quite clear about why the Case 2 can trace down to the function body of "bar". Do you have any ideas about such difference outputs?
View 3 Replies
View Related
Mar 27, 2011
When I run the following code, the .Length function returns "undefined."
var strTest = 'test';
alert(strTest.Length);
Using the typeof function, I know that JS is treating the variable as a string.
View 4 Replies
View Related
Jul 27, 2011
Here is a code I use to calculate distance b//w 2 places using google api. It works perfectly and shows the results in the html but when I add a return statement at the end of the function showlocation() it returns undefined.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL]">
<html xmlns="[URL]">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="robots" content="noindex,follow" />
<title>Calculate driving distance with Google Maps API</title>
<script src="[URL]" type="text/javascript"></script>
<!-- According to the Google Maps API Terms of Service you are required display a Google map when using the Google Maps API. see: [URL] -->
<script type="text/javascript">
var geocoder, location1,addr1,addr2, location2, result1,gDir;
function coolAl(add1,add2) {
addr1=add1;
addr2=add2;
var result= return initialize();
showLocation();
alert(result);
} function initialize() {
geocoder = new GClientGeocoder();
gDir = new GDirections();
GEvent.addListener(gDir, "load", function() {
var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
result1=location1.address + ' (' + location1.lat + ':' + location1.lon + ')/' + location2.address + ' (' + location2.lat + ':' + location2.lon + ')/' + drivingDistanceKilometers + ' kilometers';
document.body.innerHTML=result1;
return drivingDistanceKilometers;
});
} function showLocation() {
geocoder.getLocations(addr1, function (response) {
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode the first address");
} else {
location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
geocoder.getLocations(addr2, function (response) {
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode the second address");
} else {
location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
gDir.load('from: ' + location1.address + ' to: ' + location2.address);
}});}});}
</script></head>
<body onload="coolAl('pune','mumbai')">
</html>
View 9 Replies
View Related
May 11, 2011
<script>
// Declared Constants
MORSE_ALPHABET = new Array (
'.-', // A
'-...', // B
'-.-.', // C
'-..', // D
'.', // E
'..-.', // F
'--.', // G
'....', // H
'..', // I
'.---', // J
'-.-', // K
'.-..', // L
'--', // M
'-.', // N
'---', // O
'.--.', // P
'--.-', // Q
'.-.', // R
'...', // S
'-', // T
'..-', // U
'...-', // V
'.--', // W
'-..-', // X
'-.--', // Y
'--..' // Z
);
CHAR_CODE_A = 65;
var CTS = prompt('Enter Morse code','here')
var inMessage = CTS.split(' ');
searchLocation(inMessage,MORSE_ALPHABET)
function searchLocation(targetValue, arrayToSearchIn) {
var searchIndex = 0; // Iterative counter
for(i=0;i < targetValue.length;) {
targetValue = targetValue[i];
// Search until found or end of array
while( searchIndex<arrayToSearchIn.length && i != targetValue.length &&
arrayToSearchIn[searchIndex]!=targetValue) {
i++searchIndex++;
} if(searchIndex<arrayToSearchIn.length) {
return String.fromCharCode(CHAR_CODE_A + searchIndex);
} else {
return -1;
}}}
document.writeln(searchLocation(inMessage,MORSE_ALPHABET));
</script><head></head><body></body>
This is my code and I have figured it to create an array from the prompt and then use the function to return the first array it finds but I cant seem to make it go on to the next index of the array. I know that when you return a value the function closes and I have tried to store my return in a variable but its not working the way I want it to or I'm not writing the correct command or is there away to do multiply returns, I think what I need to do is simply but I have been staring at this screen for a while now and just cant see it.
View 3 Replies
View Related
Jul 30, 2010
How would you go about writing a function that returns a string that outputs a branched bulleted list using <ul> and <li> tags of all the html elements in a page? The html elements don't all have id's or names, so I cannot reference them directly. I would like to do it recursively so that I can grab all the elements, not just those two or three levels deep.
[Code]...
View 3 Replies
View Related
Nov 6, 2009
I have a simple form here with a function to validate it, but I have no idea where I'm going wrong. I'm very familiar with ActionScript and C++, so I get the coding aspect of it, but one thing I'm not familiar with is how exactly JavaScript and HTML communicate. The problem is that this form always submits, even if my function returns false...but I can't even see if it returns false anyway, because alert() doesn't seem to be working either.
Here's what I have for my HTML:
View 3 Replies
View Related
Jul 4, 2009
I have a program that calculates change and added a function to determine what currency that should be dispensed based on the change.Right now with my code as is, the calculate change portion works, also if I manually enter a value into the change field it will calculate the currency to be dispursed. My problem is I can't get it to read the value passed to the currency field from the calculate change portion. Here is my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
[code]....
View 4 Replies
View Related