It seems to be a problem with the getAttribute('style') portion of the code because if I change the request to getAttribute('id') it executes properly....
I am trying to get my script working in FF, IE and Opera but the getAttribute isn't working for me. The domain name isn't getting picked up I have tried this:
I'm trying to get the value of an object's property. getAttribute returns "null" even though I'm sure the property is set. I can easily set the property, and in my actual script I do so dynamically. I just want to read the property and can't.
To help explain my problem, I've attached an example .html file as a .txt file.
The critical part of the code is this section that is based on "textbook" examples of how to get an attribute:
<script type="text/javascript"> function showcolor() { var myobject = document.getElementById("lab"); var myproperty = myobject.getAttribute("color");
alert(myproperty); } </script>
This is called via a button on the bottom of the page. The DIV object with the ID "lab" exists and has a color attribute defined in CSS, but I cannot read it, nor any other attribute, with a script. The alert displays "null".
During development of Bing Maps, I've come across a problem when reading in an XML file and plotting a ploygon. The code works fine on IE, but FireFox is giving me the following error message: Error: xNodes[i].getAttribute is not a function
The function in its entirety is copied below and the problem line is marked in red. Hoping that someone may have come across this problem?
I am trying to get a url attribute from an xml node: <item> <media url="http://blablabla.com" /> </item>
I can do this in IE with the following code: var newDom = xmlhttp.responseXML; var x = newDom.getElementsByTagName("item"); var urlNode = x[0].getElementsByTagName('media'); var myUrl = urlNode[0].getAttribute('url');
If I try this code in FireFox it gives me the following error:
urlNode[0] has no properties referring to this line : myUrl = urlNode[0].getAttribute('url');
I want to take the current location of an position:absolute div and add 100 to its style.top value. However I can't get that value, I can set it but not retrieve its current value. Here is a sample.... Code: function moveit(elem){ alert(elem.style.top); alert(document.getElementById("question1").style.top); } Demo: [URL]
on my site, I have added Style 1 and Style 2 in my menu at the top righthttp://www.thisisworthing.com/default.php#when I click on Theme 2, it doesn't work?!I have this working on my other site: http://www.mypubspace.com
I have a strange problem using Internet Explorer. My page has a table included in a <DIV> I have a checkbox that shows the div when checked and hides it when unchecked.
var division = document.getElementById("passport") ;
Then I use division.style.visibility = "visible" ; or division.style.visibility = "hidden" ;
Everything works perfectly under FireFox or Safari showing or hidding the table.
BUT, in IExplorer 6 or 7, just checking the checkbox doesn't change anything. You have to first click on the actual division position to make it appear. Same for unchecking: click on the displayed table and it will disappear. Code:
I'm developing a web-template editor for a client, and they want it to update the changes in real-time using javascript. So, in other words, when a person selects a different background image, I use:
document.body.style.backgroundImage="url("+bgimg+")"; Well, I've run into a little problem. I can't seem to find any manual on what comes after style.*
So far, I've seen style.color, style.backgroundImage, style.backgroundRepeat, style.backgroundColor. But, I'm looking for something that can control text-decoration, font-weight and a:hover
Does anyone no where I can find a list of all properties support after style.*?
This is pretty straight forward... I want to change the cursor to the hand on a mouse event. This works just fine, if I use other cursors, but for some reason I can't get the cursor:hand to work in Firefox???
Through an onClick() event, I have an inline function to change the font size of the page (actually, I need to do this for the entire website). I have this defined in the header.cfm file as:
onclick="document.body.style.fontSize=཮%'"
This does not work at all for some reason. Whereas,
My understanding had been that $.css("width") would return the original user selected style, eg "100%" or "10em", and $.width() returned the computed width, always in "px". Not so, following the code through for .css(), it calls something called getComputedStyle and the only difference between the two functions turns out to be a post-fix of "px" on the .css() result - not very useful. I need to know whether my user has called me with a proportional dimension, or a fixed one. How to tell with jQuery?
I'm working on a slider script and it would be just lovely to be able to specify the slider's width in a width attribute on the input that represents it. In the code below, getAttribute("width") is returning 0 in IE, but seems to work fine in firefox. . . .
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript"> var curr_slide=""; var ie = (document.all && !window.opera)?1:0; if (!ie) document.captureEvents(Event.MOUSEMOVE) var tempX = 0 var tempY = 0 var slide_width=200; window.onload=function() { buildSlider(); } function buildSlider() { var sliders=getElementsByClassName(document,'input','slider'); var len=sliders.length; for(var i=0;i<len;i++) { var div=document.createElement('div'); div.className='slider_house' alert(sliders[i].getAttribute('width')); if(sliders[i].getAttribute('width')) { slide_width=sliders[i].getAttribute('width')*1; } div.style.width=(slide_width+10)*1+'px' var handle=document.createElement('div'); handle.className='handle' handle.style.left=Ɔpx' handle.onmousedown=function() { curr_slide=this; document.onmousemove=function(e) { getMouseXY(e); } document.onmouseup=function() { document.onmousemove=""; } } div.appendChild(handle); sliders[i].parentNode.insertBefore(div,sliders[i]); } } function getSlide(obj) { var s=obj.parentNode; var lft1=s.offsetLeft; var lft2=obj.offsetLeft; var num=(lft2-lft1)-1; if(ie) { num=num-10; } return num; } function getElementsByClassName(oElm, strTagName, strClassName){ var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/-/g, "-"); var oRegExp = new RegExp("(^|s)" + strClassName + "(s|$)"); var oElement; for(var i=0; i<arrElements.length; i++){ oElement = arrElements[i]; if(oRegExp.test(oElement.className)){ arrReturnElements.push(oElement); } } return (arrReturnElements) } function getMouseXY(e) { if (ie) { tempX = event.clientX + document.body.scrollLeft tempY = event.clientY + document.body.scrollTop } else { tempX = e.pageX tempY = e.pageY } if(tempX < 0) { tempX = 0 } if(tempY < 0) { tempY = 0 } n_spot=tempX-curr_slide.parentNode.offsetLeft; var c_obj=curr_slide.parentNode.nextSibling;
This is probably quite a simple problem but I can't figure out the answer. I'm working on a site that has news stories and events coming in. What I would like is to have the news stories to be styled with squares and events with discs for instance. I might be able to change the actual plug-in so the CSS affects this change, but I just wondered how I could change the list-style-type with jQuery.
if I have an html page that uses the <style> or a <link> to call a style sheet these properties aren't available to JavaScript is there a good way to access them? eg
<html> <head> <title>expandable text area</title> <style type="text/css">
I found that if I define the style(visibility...) of a Div in a CSS class, I wouldnt be able to set it through JavaScript. The only way it works is if I declare all the style attributes in the Div tag itself first. Is this how it works?
What I wanted was to get rid of offsetLeft and use "proper" way instead....but when I do:
document.getElementById('someDiv').style.left; I keep getting empty string, unless I first set it manually (in CSS or js) to some value...
if that is intended behavior(that is if I haven't f***d up something :) in my code), and there is no offsetLeft property in W3C recommendation, what is then "standard compliant" way to make browser calculate coordinates of some tag on the page???
If I didn't set the height of an html element on a web page with html attributes. Then obj.style.height always reports "0" even after the page has completely rendered. Is there any way to get the actual height after being rendered?
If I code JavaScript as if it were C code with respect to the use of semicolons, are there any caveats? I understand that I will be typing a few more semicolons than absolutely needed.