JavaScript - How To Get The Margin-left Value
I need to set a divs margin-left value into a var, ive tried a few different ways and i always get undefined, anyone able to help me? Ideally id like it without the px too but thats not essential.
Similar TutorialsWhen I click on the image I want to get the "margin-left" value of its block. In the code below the margin-left is set at 100px. But when I click on the image the "margin-left" value shows in the "alert" as undefined. What code changes do I need to get the correct margin-left value? (Please, no guessing!) [CODE] <script type="text/javascript" > window.onload = function(){ document.getElementById("holder").onclick = showit; } function showit( ) { var marval = document.getElementById("holder").style.marginLeft; alert(" margin-left= " + marval + " typeof= " + typeof marval); } </script> <style type="text/css"> #holder{ padding: 0px; margin-left: 100px; } </style> </head> <body> <img id="holder" src="anyimage.gif" width="300px" height="200px" /> </body> [CODE] Hey all, for some reason, I can't get the margin-top property to change using Code: jQ(this.centerPiece).attr('marginTop', this.imgSrcs[ this.srcs[5] ].top); also tried jQ(this.centerPiece).attr('margin-top', this.imgSrcs[ this.srcs[5] ].top); any help would be great townsendwebdd.com is the site Code: /**Scroller*/ function Scroller(){ //grab the img elements //this.imgs = new Array( '#img0', '#img1', '#img2', '#img3', '#img4', '#centerImg', '#img5', '#img6', '#img7', '#img8', '#img9' ); this.imgs = new Array( '#img0', '#img1', '#img2', '#img3', '#centerImg', '#img6', '#img7', '#img8', '#img9' ); this.centerPiece = '#centerImg'; this.centerPieceLink = '#centerA'; //set the image locations this.imgSrcs = new Array(); this.imgSrcs.push(new imgSrc('gx/tiltedNMInvestigates.png', 'gx/tiltedNMInvestigatesRight.png', 'gx/nmInvestigates.jpg', 'http://nminvestigates.townsendwebdd.com', 100 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedChess.png', 'gx/tiltedChessRight.png', 'gx/chess.jpg', 'http://townsendwebdd.com/chess', 200 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedFiveInARow.png', 'gx/tiltedFiveInARowRight.png', 'gx/fiveInARow.jpg', 'http://fiveinarow.townsendwebdd.com', 0 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedGaelsong.png', 'gx/tiltedGaelsongRight.png', 'gx/gaelsong.jpg', 'http://gaelsong.townsendwebdd.com', 100 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedGreenBay.png', 'gx/tiltedGreenBayRight.png', 'gx/greenBay.jpg', 'http://townsendwebdd.com/gx/GreenBaySite.jpg', 0 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedMillarSmith.png', 'gx/tiltedMillarSmithRight.png', 'gx/millarSmith.jpg', 'http://townsendwebdd.com/gx/millarSmith.jpg', 100 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedNanoMeds.png', 'gx/tiltedNanoMedsRight.png', 'gx/nanomeds.jpg', 'http://townsendwebdd.com/gx/nuBots2.jpg', 0 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedAlegro.png', 'gx/tiltedAlegroRight.png', 'gx/alegro.jpg', 'http://townsendwebdd.com/gx/alegro2.jpg', 300 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedApnm.png', 'gx/tiltedApnmRight.png', 'gx/apnm.jpg', 'http://townsendwebdd.com/gx/apnm.jpg', 0 ) ); //this.imgSrcs.push(new imgSrc('gx/tiltedNanoMeds.png', 'gx/tiltedNanoMedsRight.png', 'gx/nanomeds.jpg', 'http://townsendwebdd.com/gx/nuBots2.jpg') ); //this.imgSrcs.push(new imgSrc('gx/tiltedNMInvestigates.png', 'gx/tiltedNMInvestigatesRight.png', 'gx/nmInvestigates.jpg', 'http://nminvestigates.townsendwebdd.com') ); //which srcs are currently in use this.srcs = new Array(); for(var i = 0; i < this.imgSrcs.length; i++){ this.srcs.push(i); } } /** reset the current images*/ Scroller.prototype.populate = function(){ //populate imgs for(var i = 0; i < 4; i++){ jQ( this.imgs[i] ).attr('src', this.imgSrcs[ this.srcs[i] ].left ); jQ( this.imgs[i + 5] ).attr('src', this.imgSrcs[ this.srcs[i + 5] ].right); } //set the centerPiece jQ(this.centerPiece).attr('src', this.imgSrcs[ this.srcs[i] ].center); jQ(this.centerPieceLink).attr('href', this.imgSrcs[ this.srcs[i] ].href); jQ(this.centerPiece).attr('marginTop', this.imgSrcs[ this.srcs[i] ].top); } /** move everything to the Left*/ Scroller.prototype.moveLeft = function(){ //increment srcs this.incrementSrcsUp(); //animate for(var i = 0; i < this.imgs.length; i++){ if(this.imgs[i] != this.centerPiece) animate(this.imgs[i], -30); } //set the centerPiece jQ(this.centerPiece).attr('src', this.imgSrcs[ this.srcs[5] ].center); jQ(this.centerPieceLink).attr('href', this.imgSrcs[ this.srcs[5] ].href); jQ(this.centerPiece).attr('marginTop', this.imgSrcs[ this.srcs[5] ].top);/** here is the stumper*/ //move back for(i = 0; i < this.imgs.length; i++){ if(this.imgs[i] != this.centerPiece) move( this.imgs[i], 30); } //repopulate this.populate(); } /** move everything to the right*/ Scroller.prototype.moveRight = function(){ //increment srcs this.incrementSrcsDown(); //animate for(var i = 0; i < this.imgs.length; i++){ if(this.imgs[i] != this.centerPiece) animate(this.imgs[i], 30); } //set the centerPiece jQ(this.centerPiece).attr('src', this.imgSrcs[ this.srcs[5] ].center); jQ(this.centerPieceLink).attr('href', this.imgSrcs[ this.srcs[5] ].href); jQ(this.centerPiece).attr('marginTop', this.imgSrcs[ this.srcs[5] ].top);/** here is the stumper*/ //move back for(i = 0; i < this.imgs.length; i++){ if(this.imgs[i] != this.centerPiece) move( this.imgs[i], -30); } //repopulate this.populate(); } Scroller.prototype.incrementSrcsUp = function(){ for(var i = 0; i < this.srcs.length; i++){ this.srcs[i] += 1; if(this.srcs[i] >= this.srcs.length) this.srcs[i] = 0; } } Scroller.prototype.incrementSrcsDown = function(){ for(var i = 0; i < this.srcs.length; i++){ this.srcs[i] -= 1; if(this.srcs[i] < 0) this.srcs[i] = this.imgSrcs.length - 1; } } Scroller.prototype.preload = function(){ try{ for(var i = 0; i < this.imgSrcs.length; i++){ jQ('#container').append("<img src='" + this.imgSrcs[i].center + "' style='display:none;'/>"); } }catch(err){alert(err.message);} } /**the sources of the piece*/ function imgSrc(leftSrc, rightSrc, centerImg, location, topped){ this.left = leftSrc; this.right = rightSrc; this.center = centerImg; this.href = location; this.top = topped; } function animate(imgId, offsetX){ var x = jQ( imgId ).offset().left; var y = jQ( imgId ).offset().top; jQ( imgId ).offset({left: x + offsetX, top: y}); } /** function animate(imgId, offsetX){ var startLeft; var timer = setInterval(function() { imgId.style.left = ( imgId.style.left + offsetX / 10 ) + "px"; if ( imgId.style.left == startLeft + offsetX ) { clearInterval( timer ); } }, 1000); }*/ function move(imgId, offsetX){ var x = jQ( imgId ).offset().left; var y = jQ( imgId ).offset().top; jQ( imgId ).offset({left: x + offsetX, top: y}); } If anyone can help me with this problem I'd be very grateful. I'm trying to set a margin onLoad based on window size. http://jimbolgs.agilityhoster.com/handmade/test.html Thanks. Code: <script> function myfunction(){ document.getElementById('myDIV').style.marginLeft++; } </script> <body> <div id="myDIV"> This is a DIV... </div> <p> <a href="javascript:myfunction()">Do it!!</a> So, what this code is supposed to do is, every time the user click on 'Do it!!', the 'myDIV' div goes to the right. The problem is, it works only one time, why? I'm using a script for a drop down panel and it works fine, however I need to add a bit of a margin for the inner content but the script seems to be stripping it out in firefox, it works fine in ie and chrome. I've tried every trick in the book outside of editing the actual js file. I currently have a transparent image as a spacer at the top and it even ignores that. It seems that firefox just wont display anything above the first form field for some reason. Could someone take a look at this script quick and give me an idea on what to change to I can add like a 5px margin to the top of the content? Code: //** DD Drop Down Panel- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com //** Oct 21st, 08'- Script created //** March 23rd, 09' v1.01- Arrow images now preloaded function ddpanel(setting){ setting.dir="up" //initial state of panel (up="contracted") if (setting.stateconfig.persiststate && ddpanel.getCookie(setting.ids[0])=="down"){ setting.dir="down" } if (setting.dir=="up"){ //if "up", output CSS to hide panel contents document.write('<style type="text/css">\n') document.write('#'+setting.ids[1]+'{height:' + parseInt(setting.stateconfig.initial) + 'px; overflow:hidden}\n') document.write('</style>\n') } setting.stateconfig.initial=parseInt(setting.stateconfig.initial) this.setting=setting if (setting.pointerimage.enabled){ //preload images var img1=new Image(), img2=new Image() img1.src=setting.pointerimage.src[0] img2.src=setting.pointerimage.src[1] } var thispanel=this if (window.addEventListener) //if non IE browsers, initialize panel window.onload ddpanel.addEvent(window, function(e){thispanel.initpanel(setting)}, "load") else //else if IE, add 100 millisec after window.onload before initializing ddpanel.addEvent(window, function(e){setTimeout(function(){thispanel.initpanel(setting)}, 100)}, "load") ddpanel.addEvent(window, function(e){thispanel.uninit(setting)}, "unload") } ddpanel.events_array=[] //object array to contain events created by script ddpanel.addEvent=function(target, functionref, tasktype){ var evtmodel=target.addEventListener? "w3c" : "ie" var evtaction=evtmodel=="w3c"? "addEventListener" : "attachEvent" var i=this.events_array.push({ //store event info in ddpanel.events_array[] and return current event's index within array target: target, tasktype: (evtmodel=="ie"? "on" : "")+tasktype, listener: evtmodel=="ie"? function(){return functionref.call(target, window.event)} : functionref })-1 target[evtaction](this.events_array[i].tasktype, this.events_array[i].listener, evtmodel=="w3c"? false : null) } ddpanel.removeEvent=function(target, functionref, tasktype){ var evtmodel=target.removeEventListener? "w3c" : "ie" var evtaction=evtmodel=="w3c"? "removeEventListener" : "detachEvent" target[evtaction](tasktype, functionref, evtmodel=="w3c"? false : null) } ddpanel.getCookie=function(Name){ var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return null } ddpanel.setCookie=function(name, value){ document.cookie = name+"=" + value + ";path=/" } ddpanel.addpointer=function(target, className, imagesrc){ var pointer=document.createElement("img") pointer.src=imagesrc pointer.className=className pointer.style.borderWidth=0 target.appendChild(pointer) return pointer } ddpanel.prototype={ togglepanel:function(dir){ //public function that toggles the panel's state. Optional dir parameter ("up" or "down") to explicitly set state. var setting=this.setting setting.dir=dir || ((setting.dir=="up")? "down" : "up") var pcontent=setting.pcontent, dir=setting.dir pcontent._currentheight=(dir=="down")? pcontent._actualheight : setting.stateconfig.initial pcontent.style.height=pcontent._currentheight+"px" if (setting.pointerimage.enabled){ setting.arrow.src=setting.pointerimage.src[(setting.dir=="down")? 1 : 0] setting.arrow.style.visibility="visible" } ddpanel.setCookie(setting.ids[0], setting.dir) }, togglepanelplus:function(dir){ //public function that toggles the panel's state w/ animation. Optional dir parameter ("up" or "down") to explicitly set state. var setting=this.setting setting.dir=dir || ((setting.dir=="up")? "down" : "up") if (setting.pointerimage.enabled) setting.arrow.style.visibility="hidden" clearTimeout(setting.revealtimer) this.revealcontent() }, revealcontent:function(){ var setting=this.setting var pcontent=setting.pcontent, curH=pcontent._currentheight, maxH=pcontent._actualheight, minH=setting.stateconfig.initial, steps=setting.animate.steps, dir=setting.dir if (dir=="down" && curH<maxH || dir=="up" && curH>minH){ var newH = curH + (Math.round((maxH-curH)/steps)+1) * (dir=="up"? -1 : 1) newH=(dir=="down")? Math.min(maxH, newH) : Math.max(minH, newH) pcontent.style.height=newH+"px" pcontent._currentheight=newH } else{ if (setting.pointerimage.enabled){ setting.arrow.src=setting.pointerimage.src[(setting.dir=="down")? 1 : 0] setting.arrow.style.visibility="visible" } return } var thispanel=this setting.revealtimer=setTimeout(function(){thispanel.revealcontent()}, 10) }, initpanel:function(){ var setting=this.setting var pcontainer=setting.pcontainer=document.getElementById(setting.ids[0]) var pcontent=setting.pcontent=document.getElementById(setting.ids[1]) var tdiv=setting.tdiv=document.getElementById(setting.ids[2]) pcontent.style.overflow="scroll" pcontent._actualheight=pcontent.scrollHeight setTimeout(function(){pcontent._actualheight=pcontent.scrollHeight}, 100) pcontent.style.overflow="hidden" pcontent._currentheight=(setting.dir=="down")? pcontent._actualheight : setting.stateconfig.initial var thispanel=this ddpanel.addEvent(tdiv, function(e){ //assign click behavior when toggle DIV tab is clicked on if (setting.animate.enabled) thispanel.togglepanelplus() else thispanel.togglepanel() if (e.preventDefault) e.preventDefault() return false }, "click") if (setting.pointerimage.enabled){ var pointer1=new Image(), pointer2=new Image() pointer1.src=setting.pointerimage.src[0] pointer2.src=setting.pointerimage.src[1] setting.arrow=ddpanel.addpointer(tdiv.getElementsByTagName("span")[0], "pointerimage", setting.pointerimage.src[setting.dir=="down"? 1:0]) } if (setting.closepanelonclick.enabled){ //assign click behavior when panel content is clicked on (links within panel or elements with class "closepanel" ddpanel.addEvent(pcontent, function(e){ var rel="nofollow" target=e.srcElement || e.target if (/(^|\s+)closepanel($|\s+)/.test(target.className) || target.tagName=="A" || (target.parentNode && target.parentNode.tagName=="A")){ thispanel.togglepanel("up") } }, "click") } }, uninit:function(){ var setting=this.setting if (setting.stateconfig.persiststate){ ddpanel.setCookie(setting.ids[0], setting.dir) } for (prop in setting){ setting[prop]=null } } } //end of ddpanel object //initialize instance of DD Drop Down Panel: var defaultpanel=new ddpanel({ ids: ["mypanel", "mypanelcontent", "mypaneltab"], // id of main panel DIV, content DIV, and tab DIV stateconfig: {initial: "0px", persiststate: true}, // initial: initial reveal amount in pixels (ie: 5px) animate: {enabled: true, steps: 5}, //steps: number of animation steps. Int between 1-20. Smaller=faster. pointerimage: {enabled: true, src: ["arrow-down.gif", "arrow-up.gif"]}, closepanelonclick: {enabled: true} // close panel when links or elements with CSS class="closepanel" within container is clicked on? }) My code works great except that the margin and padding CSS isn't doing anything. Which doesn't make sense to me because the font size, style, and alignment is affected by the CSS. Does anyone know why this is?? Code: <h2 class="sidebar-heading">Testimonial:</h2> <html> <head> <title>Testimonies</title> <style type="text/css"> #quote { margin: 0 20px; padding-top: 20px; font-size: 1.1em; font-style: italic; text-align: left; } </style> <script type="text/javascript" language="javascript"> var testimony = new Array() testimony[1]= "<i>Testimonial 1</i>"; testimony[2]= "<i>Testimonial 2</i>"; testimony[3]= "<i>Testimonial 3</i>"; function firstTestimony() { document.getElementById('div_display').innerHTML=testimony[1]; setTimeout("secondTestimony()",2000); } function secondTestimony() { document.getElementById('div_display').innerHTML=testimony[2]; setTimeout("thirdTestimony()",2000); } function thirdTestimony() { document.getElementById('div_display').innerHTML=testimony[3]; setTimeout("firstTestimony()",2000); } </script> </head> <body> <span id="quote"> <div id="div_display"><script type="text/javascript" language="javascript">firstTestimony();</script></div> </span> </body> </html> Thanks!! I have a slider that slides the content from the top to bottom when a link/button is clicked. I want it to slide out from the right side of the button and move left to right. Is this possible by just adjusting the code I already have? Thanks. HTML: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>jQuery Accordion Style DIV Menu</title> <link href="format.css" rel="stylesheet" type="text/css" /> <link href="text.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script> <script type="text/javascript" src="javascript.js"> </script> </head> <body> <div id="wrapper"> <div class="accordionButton">Button 1 Content</div> <div class="accordionContent">Content 1<br /><br /><br /><br /><br /><br /><br /><br />Long Example</div> <div class="accordionButton">Button 2 Content</div> <div class="accordionContent">Content 2<br /><br /><br /><br /><br />Medium Example</div> <div class="accordionButton">Button 3 Content</div> <div class="accordionContent">Content 1<br />Short Example</div> <div class="accordionButton">Button 4 Content</div> <div class="accordionContent">Content 4<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />Extra Long Example</div> </div> </body> </html> javascript.js: Code: $(document).ready(function() { //ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING) $('.accordionButton').click(function() { //REMOVE THE ON CLASS FROM ALL BUTTONS $('.accordionButton').removeClass('on'); //NO MATTER WHAT WE CLOSE ALL OPEN SLIDES $('.accordionContent').slideUp('normal'); //IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT if($(this).next().is(':hidden') == true) { //ADD THE ON CLASS TO THE BUTTON $(this).addClass('on'); //OPEN THE SLIDE $(this).next().slideDown('normal'); } }); /*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/ //ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER $('.accordionButton').mouseover(function() { $(this).addClass('over'); //ON MOUSEOUT REMOVE THE OVER CLASS }).mouseout(function() { $(this).removeClass('over'); }); /*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/ /******************************************************************************************************************** CLOSES ALL S ON PAGE LOAD ********************************************************************************************************************/ $('.accordionContent').hide(); }); on my page: http://www.jbiddulph.com/john-drag.html I want to be able to show the TOP and LEFT position on the textboxes below when I move the box?! Please help?! thanks J Good morning, I'm using the TDC JavaScript Ticker code and would like to have the data scroll from right to left. Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="sagscroller.css" /> <script type="text/javascript"> //Note- Below example by JavaScriptKit.com function tdcticker(){ tickerSet.MoveNext(); if (tickerSet.EOF) //if end of data's file tickerSet.MoveFirst() setTimeout("tdcticker()",9000); } function init(){ tickerSet=ticker.recordset tickerSet.moveFirst() setTimeout("tdcticker()",9000) } </script> <a href="" datasrc="#ticker" class="ticker" datafld="messageURL" style="width:260px; border:0px solid black;"> <span id="tickerDiv" datasrc="#ticker" datafld="MESSAGES" ></span> </a> <script type="text/javascript"> if (document.all) ticker.ondatasetcomplete=init </script> Thanks in advance! I'm not very experienced with javascript, but I have a bit of code that works perfectly for me that expands/collapses a div without any animation from top to bottom. I'm looking for the same exact code that lets me expand/collapse from left to right. I've done my due diligence and have search many forums with limited luck (I've only found one that is animated that I can't turn off the animation). Can someone point me in the right direction to code that does exactly the same as what I've posted below except from left to right? Code: // code to keep collapsed on opening function pageLoad() { collapseAll($('wrapper1-sub','wrapper2-sub','wrapper3-sub','wrapper4-sub','wrapper5-sub','wrapper6-sub','wrapper7-sub','wrapper8-sub','wrapper9-sub','wrapper10-sub','wrapper11-sub','wrapper12-sub')); } addEvent(window,'load',pageLoad); //code to work the collapse function switchMenu(obj) { var el = document.getElementById(obj); if ( el.style.display != "none" ) { el.style.display = 'none'; } else { el.style.display = ''; } } function collapseAll(objs) { var i; for (i=0;i<objs.length;i++ ) { objs[i].style.display = 'none'; } } function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } function addEvent( obj, type, fn ) { if (obj.addEventListener) { obj.addEventListener( type, fn, false ); EventCache.add(obj, type, fn); } else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } obj.attachEvent( "on"+type, obj[type+fn] ); EventCache.add(obj, type, fn); } else { obj["on"+type] = obj["e"+type+fn]; } } var EventCache = function(){ var listEvents = []; return { listEvents : listEvents, add : function(node, sEventName, fHandler){ listEvents.push(arguments); }, flush : function(){ var i, item; for(i = listEvents.length - 1; i >= 0; i = i - 1){ item = listEvents[i]; if(item[0].removeEventListener){ item[0].removeEventListener(item[1], item[2], item[3]); }; if(item[1].substring(0, 2) != "on"){ item[1] = "on" + item[1]; }; if(item[0].detachEvent){ item[0].detachEvent(item[1], item[2]); }; item[0][item[1]] = null; }; } }; }(); addEvent(window,'unload',EventCache.flush); Hi friends, <script language="JavaScript" > calDocFrameset = "<frameset rows='60,*' frameborder='0' sty >\n" + " <frame name='topCalFrame' src='javascriptarent.opener.calDocTop' scrolling='no'>\n" + " <frame name='bottomCalFrame' src='javascriptarent.opener.calDocBottom' scrolling='no'>\n" + "</frameset>\n"; document.write(calDocFrameset); </script> the above code i am using for popup calendar. It is working fine with IE.But it is not working in mozilla and GoogleChrome. In mozilla and gc it is comming in center. It is appearing only when i maximize the window. Even though i have given window properties as window.open('/includes/calendar.htm','cal','dependent=yes,width=180,height=180,left=400,top=250,titlebar=yes,resize=no'); I want the calendar to appear in popupwindow without maximizing. Srikanth So I have a list of values in an xml document. 1. Tom 2. Ned 3. Steve 4. Bob 5. Rob If I leave/refresh the page, I start back at the 1st entry (Tom). I would like to return the viewer to where the viewer left off. Example, if user exists at Steve, I would like to resume him when he returns at Bob. Is this possible using Javascript/XML? Hi All, I have been searching the net for a tutorial of how to create a left to right slider when a link is clicked. Basically I want have the div hidden initially then when a link is clicked the div to slide out over the top of my current content. I can find plenty of tutorials of examples where the div slides up and down but not from left to right.. Can anyone help me out here? many thanks, greens85 Hi, I want the image in the header of my website to move from left to right and back in an endless loop. The image width is larger than the width of the div which contains the image, so when the image moves to the right, the right end of the image has to disappear. When the image moves back to the left, the left end has to disappear. Now I know I can use the overflow: hidden; element in the CSS file to hide a part of the image. I found already several javascript scripts to move an image over the screen, but these scripts move the image only in 1 direction. I need it to go in the 2 directions in loop. Also these scripts require a position: relative; element to the image, so the hidden overflow of the div doesn't work. An example of this kind of script: Code: <body onload="moveRight()"> <div id="header" style="width: 1010px;height: 170px;overflow: hidden;"> <img src="images/header.jpg" id="header" style="position:relative;top:0px;left:0px; "> </div> <script type="text/javascript"> var userWidth = window.screen.width; function moveRight() { var pp = document.getElementById("header"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveRight()",100); // 100 controls the speed lft = lft+3; // move by 3 pixels pp.style.left = lft+"px"; if (lft > 50) { // left edge of image past the right edge of screen pp.style.left = 0; // back to the left } } </script> </body> Is there any way to improve this script to my requirements, or am I completely looking in the wrong direction? Hi, i have a container div with many other nested divs inside e.g. Code: <div id="thisOne"> <div>Div 1</div> <div>Div 2</div> </div> The outter div is 640 (ish) px wide, and the div will scroll on the across horizontally. I want it to scroll left if the mouse is in the first 100px on the left (0-100px) or right if its in the last 100 px (540-640px). What would be the best way of doing this? Sorry if that didnt make sense :P I am able to align the tooltip using the offset command, but would like to align the tooltip to open in the upper left of the screen. How can I do this? Thanks, Wina Hi, Here's a sample division: Code: <div style="padding:0 0 0 30px; background:url(http://www.google.com/help/hc/images...ent_bubble.gif) left center no-repeat;">some text</div> I wonder how I can calculate the padding-left:30px dynamically so that any icon I choose the padding-left value changes according to the image width. Any help is appreciated! Hi, I am looking for the equivalent for the following Internet Explorer code for Firefox: Code: z=event.srcElement; z.style.pixelLeft = 500px; Must be something like: Code: function move(e) { z=e.target; z.style.left ..... maybe. This is to assign a new left position to an Element. Any hints welcome ?! Thank you for your help ! I am trying to assign the left and right arrows, but I cannot get the code to work. It would be great to get some help--I am a newbie to coding. <html> <head> <script language="javascript" type="text/javascript"> document.onkeydown=function(e) { var thelink if (e.keyCode==37) thelink='prevlink' else if (e.keyCode==39) thelink='nextlink' else return document.location.href=document.getElementById(thelink).href} </script> </head> <body> <a href="#" onkeydown="return previous(this)" id="prevlink">PREVIOUS</a><br /> <br /> <a href="#" onkeydown="return next(this)" id="nextlink">NEXT</a> </body> </html> Hi On the following URL on the iphone and Ipad the jqzoom script is showing the enlarged image on the left but works fine in IE, Chrome, Firefox etc. The script in use is jqzoom. http://tinyurl.com/bwcxf8c Any idea welcome. Thanks Roy |