JavaScript - Help With Basic Javascript - Scroller List
I have a basic scroller list code, which works when I use it on a HTML page. However if I duplicate it and change the text, only one of the lists functions.
I even tried to use a script from a free website online and duplicate that on the page and it still does not work twice. Could somebody help with this? Similar TutorialsHi I have a javascript scroller on my site which was added automatically by the web design progam Web Page Maker. It works well..... but..... does anybody know how to make the scrolling faster on mousedown. Its painfully slow at the moment. I dont know ANYTHING about javascripting really. heres the code: <div id="g_iFrame1div" style="position:absolute; left:68px; top:273px; z-index:29"> <table border="0" cellpadding="0" cellspacing="0" width=628> <tr><td> <iframe src="iframes/news_latest.htm" name="g_iFrame1" width="606" height="487" src="" scrolling="no" frameborder="0"></iframe> </td><td align="center" valign="middle" width="22"><img src="arrow_up.gif" alt="up" border=0 vspace="5" hspace="3" onMouseDown="esh_g_iFrame1();bsh_g_iFrame1(-3,2)" onMouseUp="esh_g_iFrame1();bsh_g_iFrame1(-1,20)" onMouseOver="bsh_g_iFrame1(-1,20)" onMouseOut="esh_g_iFrame1()"><br> <img src="arrow_down.gif" alt="down" border=0 vspace="5" hspace="3" onMouseDown="esh_g_iFrame1();bsh_g_iFrame1(3,2)" onMouseUp="esh_g_iFrame1();bsh_g_iFrame1(1,20)" onMouseOver="bsh_g_iFrame1(1,20)" onMouseOut="esh_g_iFrame1()"> <script type="text/javascript" language="javascript"> function bsh_g_iFrame1(step,time){hs_g_iFrame1=setInterval("sh_g_iFrame1("+step+")",time)} function esh_g_iFrame1(){clearInterval(hs_g_iFrame1)} function sh_g_iFrame1(step) { scrollx=g_iFrame1.document.body.scrollLeft scrolly=g_iFrame1.document.body.scrollTop scrolly=scrolly+step g_iFrame1.window.scroll(scrollx,scrolly) } </script> thanks Stuey Hi guys, I have a little experience in Javascript and would like to learn a bit more etc. I am currently working for a company which wants me create / find a image scroller using javascript and jquery. I found one which seems very suitable... I have customized the CSS and have coded it all up... The problem i'm having is that the image scroller is scrolling 3 images at a time. I would like it to scroller one at a time whilst showing all the images... Example scroller: [ pic 1] [pic 2] [pic 3] [pic 4] after scroll [pic 2] [pic 3] [pic 4] [pic 1] after next scroll [pic 3] [pic 4] [pic 1] [pic 2] and so forth. If you look at this code you will see what I mean... please help me learn and please help me complete this... im sure its just a little adjustment... but me not being too great at javascript... it makes me feel like im shooting in the dark. Thanks alot Code: <style type="text/css" media="screen"> <!-- body { font: 1em "Trebuchet MS", verdana, arial, sans-serif; font-size: 100%; } input, textarea { font-family: Arial; font-size: 125%; padding: 7px; } label { display: block; } #textbanner {width:168px; height:118px; float:left;} .infiniteCarousel { width: 618px; position: relative; } .infiniteCarousel .wrapper { width: 618px; /* .infiniteCarousel width - (.wrapper margin-left + .wrapper margin-right) */ height: 115px; margin: 0 0px; position: relative; top: 0; border: 1px solid #E1E1E1; } .infiniteCarousel ul a img { border: 0px solid #666; -moz-border-radius: 5px; -webkit-border-radius: 5px; } .infiniteCarousel .wrapper ul { width: 625px; /* single item * n */ list-style-image:none; list-style-type:none; margin:0; padding:0px 0px 0px 4px; position: absolute; top: 0px; left: 0px; } .infiniteCarousel ul li { display:block; float:left; padding: 0px 0px 0px 0px; height: 85px; width: 206px; } .infiniteCarousel ul li img { -webkit-transition: border-color 20ms; } .infiniteCarousel ul:hover li img { border-color: #666; } .infiniteCarousel ul:hover li:hover img { border-color: #000; } .infiniteCarousel ul li a img { display:block; } .infiniteCarousel .forward { background-position: 0 0; right: 0; } .infiniteCarousel .back { background-position: 0 -72px; left: 0; } .infiniteCarousel .forward:hover { background-position: 0 -36px; } .infiniteCarousel .back:hover { background-position: 0 -108px; } --> </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> (function () { $.fn.infiniteCarousel = function () { function repeat(str, n) { return new Array( n + 1 ).join(str); } return this.each(function () { // magic! var $wrapper = $('> div', this).css('overflow', 'hidden'), $slider = $wrapper.find('> ul').width(9999), $items = $slider.find('> li'), $single = $items.filter(':first') singleWidth = $single.outerWidth(), visible = Math.ceil($wrapper.innerWidth() / singleWidth), currentPage = 1, pages = Math.ceil($items.length / visible); /* TASKS */ // 1. pad the pages with empty element if required if ($items.length % visible != 0) { // pad $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible))); $items = $slider.find('> li'); } // 2. create the carousel padding on left and right (cloned) $items.filter(':first').before($items.slice(-visible).clone().addClass('cloned')); $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned')); $items = $slider.find('> li'); // 3. reset scroll $wrapper.scrollLeft(singleWidth * visible); // 4. paging function function gotoPage(page) { var dir = page < currentPage ? -1 : 1, n = Math.abs(currentPage - page), left = singleWidth * dir * visible * n; $wrapper.filter(':not(:animated)').animate({ scrollLeft : '+=' + left }, 1000, function () { // if page == last page - then reset position if (page > pages) { $wrapper.scrollLeft(singleWidth * visible); page = 1; } else if (page == 0) { page = pages; $wrapper.scrollLeft(singleWidth * visible * pages); } currentPage = page; }); } // 6. bind the back and forward links $('a.back', this).click(function () { gotoPage(currentPage - 1); return false; }); $('a.forward', this).click(function () { gotoPage(currentPage + 1); return false; }); $(this).bind('goto', function (event, page) { gotoPage(page); }); // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL $(this).bind('next', function () { gotoPage(currentPage + 1); }); }); }; })(jQuery); $(document).ready(function () { // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL var autoscrolling = true; $('.infiniteCarousel').infiniteCarousel().mouseover(function () { autoscrolling = false; }).mouseout(function () { autoscrolling = true; }); setInterval(function () { if (autoscrolling) { $('.infiniteCarousel').trigger('next'); } }, 500); }); </script> </head> <body> <div id="textbanner"><img src="http://i46.tinypic.com/2r423yc.jpg" alt="" width="168" height="117" /></div> <div class="infiniteCarousel"> <div class="wrapper"> <ul> <li><a href="www.google.com"><img src="http://i49.tinypic.com/eu4x81.jpg" alt="" width="202" height="116" /></a></li> <li><img src="http://i49.tinypic.com/2ex8ttw.jpg" alt="" width="202" height="116" /></li> <li><img src="http://i45.tinypic.com/2gy0pkz.jpg" alt="" width="202" height="116" /></li> </ul> </div> </div> </body> </html> Hi, I've just started learning JavaScript - actually started about half an hour ago. I have an extensive knowledge of Lua (if you've heard of it), so the concepts of programming aren't new to me. This code isn't doing anything. The HTML code makes the hyper-linked pictured show, but it doesn't do anything when the mouse rolls over it. The JavaScript code is saved in scripts/titleImage_rollover.js, and I'll show the HTML code as well. JavaScript: Code: <!-- // image rollover for header function image_rollover(){ //show a set of random images switch(math.floor(math.random()*5+1)) { case 1: document.getElementById("logo").src = "images/t2m_logo.png"; break; case 2: document.getElementById("logo").src = "images/pighead10_halloween.png"; break; case 3: document.getElementById("logo").src = "images/pighead10_easter.png"; break; case 4: document.getElementById("logo").src = "images/pighead10_classic.png"; break; case 5: document.getElementById("logo").src = "images/pighead10_combat.png"; break; } } //reset image to normal function image_reset(){ document.getElementById("logo").src = "images/pighead10.png"; } //--> 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=utf-8" /> <title>pighead10.com | Home</title> <style type="text/css"> .link1 A:link{text-decoration:none;} .link1 A:visited{text-decoration:none;} .link1 A:active{text-decoration:none;} .link1 A:hover{text-decoration:underline;color:blue;} </style> <script type="text/javascript" src="scripts/titleImage_rollover.js"></script> </head> <body style="font-family:arial;color:red"> <a href="http://www.roblox.com/User.aspx?ID=2969907"> <img id="logo" src="images/pighead10.png" width="150" height="200" onmouseover="image_rollover()" onmouseleave="image_reset()"/> </a> </body> </html> Also, is there a way to view some kind of output in JavaScript? Hi, I'm trying to create a video box on a website that plays a youtube video and then automatically plays random recommended videos with no break in playback. An endless playlist created by youtube based on the initial video. Youtube uses Javascript API. I have never used Javascript before but i'm just trying to get the video to play as above. There are few tutorials online and I couldn't find anyone trying to do a similar thing. If you have any idea how i'd go about it or if not where i could find some information to help. Thanks. Hey guys! New user here and I just need a little help with some basic Javascript I must write a function that 'shows' the corresponding part of the form depending on what the user has selected. So... for example, if I select 'Pizza', the div #section2 with the question about Pizza type should be shown. All the sections that are not selected should be hidden. For example, if 'Mexican' is selected, the sections for 'Pizza' and 'Thai' should be hidden. I want this function to also display a message in the JavaScript console indicating which food type is selected. Apparently I'm supposed to use 'console.log("")'??? I'm using an external javascript file called prac8.js If anyone has any idea how to do this I'd be very greatful Code: <!DOCTYPE html> <html> <head> <title>Prac 8 example</title> <script type="text/Javascript" src="prac8.js"></script> <style> #section2, #section3, #section4 { display:none; border:1px solid gray; padding:8px; margin-top:12px; width:400px; } #dessertmsg { color:green; } </style> </head> <body> <h1>Prac 8 example</h1> <h2>A Food Survey</h2> <form id="survey" action="#" method="post"> <div id="section1"> <label for="food">What is your favourite type of food?</label> <select id="food" onchange="selection()"> <option value="pizza">Pizza</option> <option value="mex">Mexican</option> <option value="thai">Thai</option> </select> </div> <div id="section2"> What is your favourite type of pizza?<br> <label for="hawaiian">Hawaiian</label><input type="radio" id="hawaiian"> <label for="supreme">Supreme</label><input type="radio" id="supreme"> <label for="vegetarian">Vegetarian</label><input type="radio" id="vegetarian"> </div> <div id="section3"> What is your favourite Mexican food?<br> <label for="burrito">Burritos</label><input type="radio" id="burrito"> <label for="chilli">Chilli con carne</label><input type="radio" id="chilli"> <label for="taco">Tacos</label><input type="radio" id="taco"> </div> <div id="section4"> What is your favourite Thai food?<br> <label for="stir">Stir-fry</label><input type="radio" id="stir"> <label for="noodle">Noodles</label><input type="radio" id="noodle"> <label for="curry">Curry</label><input type="radio" id="curry"> </div> <label for="dessert">What is your favourite dessert?*</label> <input type="text" id="dessert" onchange="checkForm()"><br> <div id="dessertmsg"> </div> <input type="submit" value="Submit" id="subbutton" disabled> </form> </body> </html> Hi so i am using onClick="myPopup(); on a button and when someone clicks on the button, it pops up an advertisement in a new tab. But is there a way to make the users stay on the page where the button is located instead of forcing the browser to automatically switch to the advertisement tab when a button is clicked? Hey guys. I am pretty new to JS and programming. The company that I am working for put me on this project and I have a question. Here is a snippit for a form that we have. We use a dreamweaver extension "HDW form to database" to process the forms and put them in a mysql database. the wpform() is a validation function that has been written. what I want, is the fallowing, if you look at the code below in the option object, there are different categories... rock, funk, hip hop, synth etc. i want it so when one of them is selected, it goes to a different respected page. for example, if the value Rock is selected, and you press submit, it would take you to www.google.com . On the other hand if the value Funk is submitted, it will take you to www.yahoo.com . Code: <form action="/HDWFormToDatabase/FormToDatabase.php" method="post" name="theForm" onSubmit="return wpform()" accept-charset="iso-8859-1"> <select size="1" name="genre"> <option selected="selected" value="genre">Choose a Genre!</option> <option value="Rock">Rock</option> <option value="Funk">Funk</option> <option value="Hip Hop">Hip Hop</option> <option value="80s">Synthesizer</option> <option value="Techno">Techno</option> </select> <input type="hidden" name="hdwok" id="hdwok" value=" URL GOES HERE" /> </form> Normally, when this option object is not present, the user presses submit and after the form gets processed to the database, the browser forwards to the "URL GOES HERE" value. However, I am not sure exactly what to do now since the URL which it is forwarded to will change. can someone give me a hint on how to make this happen? just some general advice for a newb? I would write it but I am pretty lost. I was thinking of including a if statement in the wpform() function that goes something like: Code: if (document.theForm.genre.selectedIndex == 0) { alert("Please select your genre."); document.theForm.genre.focus(); return (false); } if (document.theForm.genre.selectedIndex==1) { window.location = "http://www.google.com/"; return(true); } if (document.theForm.genre.selectedIndex==2) { window.location = "http://www.yahoo.com/"; return(true); } etc etc Would this work? Is there a more efficient way of doing something like this that I should know of due to my lack of JS skills? Thanks in advance so much for help. Hello All Its my first post on this forum. I have a database setup with tables that use my form element names as column names. Now i have successfully retrieved column names and values from the server side to the client side. . I have the column name stored in var columnName How can I get the type of form element type and how can i set the value to it Thanks for your help #Javalove. . .unless otherwise stated. . .! I'm stumped. I realise it's something basic... This works - i.e. beeps on mouseover: Code: <html> <head> <script> function EvalSound(soundobj) { var thissound= eval("document."+soundobj); thissound.Play(); } </script> </head> ... <a href="#" onMouseOver="EvalSound('sound1')">Move mouse here</a> ... <embed src="beep.mp3" autostart=false width=1 height=1 name="sound1" enablejavascript="true"> </body> </html> ...but this doesn't work: (I get the error "undefined is null or not an object") Code: <html> <head> <script> function EvalSound(soundobj) { var thissound= eval("document."+soundobj); thissound.Play(); } </script> </head> ... <script language="JavaScript"> <!-- EvalSound('sound1'); change_it1() // activates an external .js //--> </script> ... <embed src="beep.mp3" autostart=false width=1 height=1 name="sound1" enablejavascript="true"> </body> </html> What am I doing wrong? Gotta make the second idea work... Thanks hi all, just got to make a basic form for my assignemment but i cant seem to get it to work. please could somebody point me in the right direction? thank you Code: <head> <script type="text/javascript"> function make(myform) { var name = form.nameinput.value ; var age = form.ageinput.value ; var location = form.locationinput.value ; var z = form.team.selectedIndex ; var team = form.team.options[z].value; alert("Thank you " + name + ".Good luck supporting " + team + ); } </script> </head> <body> <form method="get" action="" name="myform"> <h2>Order form</h2> <fieldset> <p>Please enter your details</p> Name: <input type="text" value="" name="nameinput"/><br/> Age: <input type="text" value="" size="2" name="ageinput"/><br/> Location: <input type="text" value="" name="locationinput"/> <p>Choose your favourite football team</p> <select name="team"> <option value="arsenal">Arsenal</option> <option value="aston_villa">Aston Villa</option> <option value="birmingham_city">Birmingham City</option> <option value="blackburn_rovers">Blackburn Rovers</option> <option value="bolton_wanderers">Bolton Wanderers</option> <option value="burnley">Burnley</option> <option value="chelsea">Chelsea</option> <option value="everton">Everton</option> <option value="fulham">Fulham</option> <option value="hull">Hull</option> <option value="liverpool">Liverpool</option> <option value="manchester_city">Manchester City</option> <option value="manchester_united">Manchester United</option> <option value="portsmouth">Portsmouth</option> <option value="stoke_city">Stoke City</option> <option value="sunderland">Sunderland</option> <option value="tottenham_hotspur">Tottenham Hotspur</option> <option value="west_ham">West Ham</option> <option value="wigan_athletic">Wigan Athletic</option> <option value="wolverhampton_wanderers">Wolverhampton Wanderers </option> </select> </fieldset> <input type="button" onclick="make(this.form)" value="Submit Details" name="button"/> </form> This must be very simple. I want to execute some javascript only if an element is not displayed What is the syntax? if("#element:hidden) { do something like show it } Help much appreciated. Hi, I'm very much a newbie regaridng javascript and have been looking around and experimenting and have created a javascript although it does not function(Javascript code below), can someone help me fix it? Many Thanks. function gotoURL(){ var newURL = document.GotoForm.theURL.value if (newURL == "info1" || "info2" || "info3" || "info4" || "info 5"){ document.location.href=newURL+".html" }else{ alert("You entered an invalid value"); }} Hi guys, I am new to learning javascript and have a test tomorrow on for loops. I know the answers to the three following loops but i wondered if anyone could take the time to explain to me how to find the answer from the code as I have no idea on how to find the answers (the answer is what is displayed in the alert). Many thanks, Mike The loops are these three: 1. var a=4;b=6; for(var c=0;c<=a;c++){b=b+c;} alert(b); (answer is 16) 2. var v=1; for(i=1;i<5;i++) for(j=2;j<5;j++) v+=1; alert(v); (answer is 13) 3. var s=0; for(i=0;i<=8;i++) if((i%2)==0)s+=1; alert(s); (answer is 5) Hi, im sorta a newbie but have a few questions i cannot find online anywhere. By the way im trying to create a chrome extension . Its a fairly simple extension, all i want it to do is select a few buttons automatically when the page is loaded. Without me having to click anything. A bot persay. How to automatically select a button/drop down menu How to save a form How to submit a form to a website How it works if you dont get it? Selecting a certain size like S/M/L, color, or anything of that nature AUTOMATICALLY WITHOUT HAVING TO CLICK ANYTHING. Which then adds to my cart. Thats all i want it to really do. Thanks for reading. Hello, I am a computing pupil currently taking part in a computer science project at GCSE level. Our project is a research task regarding web form validation, JavaScript and embedding JavaScript into HTML code. I have no prior knowledge of any of these topics, so would be very interested in hearing your opinions on the aboce. I would also like to know your opinion on how effective JavaScript validation is, possibly in your field of work, or just your experience of using it? Thanks in advance, Ellen I'm building a website to catalog a history of college football uniforms, and having something like this on several of the pages would be extremely helpful. I've been told that making it in Javascript instead of Flash would be better for my website. I've also been told that it should be relatively easy to write the code for it. In short, I want to be able to take the parts of this image and allow viewers of the site to be able to switch between parts to mix and match. There are quite a few teams with six or more possible uniform combinations, so I'd like to be able to do this for the site. This would probably be a good way to get my start on learning at least some Javascript basics, so would anyone be willing to help me put this together? Hello, Is there a way with JavaScript to easily detect which mobile browser is being used? I would not normally ask this, but because we do not have the time or budget to implement any back end detection scripting it is our only option right now! I don't think we will need to detect which version of the browser, or which revision of the phone is used - just need to target each family to deliver the proper video type. I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank I've got a code. I've listed it below. The only question I have which I am sure I'm just overlooking it, but I need to find a way to squeeze this to the top of the screen and to the left. Where can I modify this on this code? The first section is the whole file. Thanks! Edit: I'm trying to remove the awkward gap on top and to the left. I merged the .js file since this will only be a file that is updated with new news. Code: <html> <head> <script type="text/javascript"> /* Text and/or Image Crawler Script v1.5 (c)2009-2011 John Davenport Scheuer as first seen in http://www.dynamicdrive.com/forums/ username: jscheuer1 - This Notice Must Remain for Legal Use updated: 4/2011 for random order option, more (see below) */ /* Update 4/2011 to v1.5 - Adds optional random property. Set it to true to use. Fixes browser crash from empty crawlers, ad and image blocking software/routines. Fixes behavior in some IE of breaking script if an image is missing. Adds alt attributes to images without them to aid in diagnosis of missing/corrupt images. This may be disabled with the new optional noAddedAlt property set to true. Internal workings enhanced for greater speed of execution, less memory usage. */ ///////////////// No Need to Edit - Configuration is Done in the On Page Call(s) ///////////////// function marqueeInit(config){ if(!document.createElement) return; marqueeInit.ar.push(config); marqueeInit.run(config.uniqueid); } (function(){ if(!document.createElement) return; marqueeInit.ar = []; document.write('<style type="text/css">.marquee{white-space:nowrap;overflow:hidden;visibility:hidden;}' + '#marq_kill_marg_bord{border:none!important;margin:0!important;}<\/style>'); var c = 0, tTRE = [/^\s*$/, /^\s*/, /\s*$/, /[^\/]+$/], req1 = {'position': 'relative', 'overflow': 'hidden'}, defaultconfig = { style: { //default style object for marquee containers without configured style 'margin': '0 auto' }, direction: 'left', inc: 2, //default speed - pixel increment for each iteration of a marquee's movement mouse: 'pause' //default mouseover behavior ('pause' 'cursor driven' or false) }, dash, ie = false, oldie = 0, ie5 = false, iever = 0; /*@cc_on @*/ /*@if(@_jscript_version >= 5) ie = true; try{document.documentMode = 2000}catch(e){}; iever = Math.min(document.documentMode, navigator.appVersion.replace(/^.*MSIE (\d+\.\d+).*$/, '$1')); if(iever < 6) oldie = 1; if(iever < 5.5){ Array.prototype.push = function(el){this[this.length] = el;}; ie5 = true; dash = /(-(.))/; String.prototype.encamel = function(s, m){ s = this; while((m = dash.exec(s))) s = s.replace(m[1], m[2].toUpperCase()); return s; }; } @end @*/ if(!ie5){ dash = /-(.)/g; function toHump(a, b){return b.toUpperCase();}; String.prototype.encamel = function(){return this.replace(dash, toHump);}; } if(ie && iever < 8){ marqueeInit.table = []; window.attachEvent('onload', function(){ marqueeInit.OK = true; for(var i = 0; i < marqueeInit.table.length; ++i) marqueeInit.run(marqueeInit.table[i]); }); } function intable(el){ while((el = el.parentNode)) if(el.tagName && el.tagName.toLowerCase() === 'table') return true; return false; }; marqueeInit.run = function(id){ if(ie && !marqueeInit.OK && iever < 8 && intable(document.getElementById(id))){ marqueeInit.table.push(id); return; } if(!document.getElementById(id)) setTimeout(function(){marqueeInit.run(id);}, 300); else new Marq(c++, document.getElementById(id)); } function trimTags(tag){ var r = [], i = 0, e; while((e = tag.firstChild) && e.nodeType === 3 && tTRE[0].test(e.nodeValue)) tag.removeChild(e); while((e = tag.lastChild) && e.nodeType === 3 && tTRE[0].test(e.nodeValue)) tag.removeChild(e); if((e = tag.firstChild) && e.nodeType === 3) e.nodeValue = e.nodeValue.replace(tTRE[1], ''); if((e = tag.lastChild) && e.nodeType === 3) e.nodeValue = e.nodeValue.replace(tTRE[2], ''); while((e = tag.firstChild)) r[i++] = tag.removeChild(e); return r; } function randthem(tag){ var els = oldie? tag.all : tag.getElementsByTagName('*'), i = els.length - 1, childels = [], newels = []; for (i; i > -1; --i){ if(els[i].parentNode === tag){ childels.push(els[i]); newels.push(els[i].cloneNode(true)); } } newels.sort(function(){return 0.5 - Math.random();}); i = childels.length - 1; for (i; i > -1; --i){ tag.replaceChild(newels[i], childels[i]); } } function Marq(c, tag){ var p, u, s, a, ims, ic, i, marqContent, cObj = this; this.mq = marqueeInit.ar[c]; if(this.mq.random){ randthem(tag); } for (p in defaultconfig) if((this.mq.hasOwnProperty && !this.mq.hasOwnProperty(p)) || (!this.mq.hasOwnProperty && !this.mq[p])) this.mq[p] = defaultconfig[p]; this.mq.style.width = !this.mq.style.width || isNaN(parseInt(this.mq.style.width))? '100%' : this.mq.style.width; if(!tag.getElementsByTagName('img')[0]) this.mq.style.height = !this.mq.style.height || isNaN(parseInt(this.mq.style.height))? tag.offsetHeight + 3 + 'px' : this.mq.style.height; else this.mq.style.height = !this.mq.style.height || isNaN(parseInt(this.mq.style.height))? 'auto' : this.mq.style.height; u = this.mq.style.width.split(/\d/); this.cw = this.mq.style.width? [parseInt(this.mq.style.width), u[u.length - 1]] : ['a']; marqContent = trimTags(tag); tag.className = tag.id = ''; tag.removeAttribute('class', 0); tag.removeAttribute('id', 0); if(ie) tag.removeAttribute('className', 0); tag.appendChild(tag.cloneNode(false)); tag.className = ['marquee', c].join(''); tag.style.overflow = 'hidden'; this.c = tag.firstChild; this.c.appendChild(this.c.cloneNode(false)); this.c.style.visibility = 'hidden'; a = [[req1, this.c.style], [this.mq.style, this.c.style]]; for (i = a.length - 1; i > -1; --i) for (p in a[i][0]) if((a[i][0].hasOwnProperty && a[i][0].hasOwnProperty(p)) || (!a[i][0].hasOwnProperty)) a[i][1][p.encamel()] = a[i][0][p]; this.m = this.c.firstChild; if(this.mq.mouse === 'pause'){ this.c.onmouseover = function(){cObj.mq.stopped = true;}; this.c.onmouseout = function(){cObj.mq.stopped = false;}; } this.m.style.position = 'absolute'; this.m.style.left = '-10000000px'; this.m.style.whiteSpace = 'nowrap'; if(ie5) this.c.firstChild.appendChild((this.m = document.createElement('nobr'))); if(!this.mq.noAddedSpace) this.m.appendChild(document.createTextNode('\xa0')); for(i = 0; marqContent[i]; ++i) this.m.appendChild(marqContent[i]); if(ie5) this.m = this.c.firstChild; ims = this.m.getElementsByTagName('img'); if(ims.length){ for(ic = 0, i = 0; i < ims.length; ++i){ ims[i].style.display = 'inline'; if(!ims[i].alt && !this.mq.noAddedAlt){ ims[i].alt = (tTRE[3].exec(ims[i].src)) || ('Image #' + [i + 1]); if(!ims[i].title){ims[i].title = '';} } ims[i].style.display = 'inline'; ims[i].style.verticalAlign = ims[i].style.verticalAlign || 'top'; if(typeof ims[i].complete === 'boolean' && ims[i].complete) ic++; else { ims[i].onload = ims[i].onerror = function(){ if(++ic === ims.length) cObj.setup(c); }; } if(ic === ims.length) this.setup(c); } } else this.setup(c) } Marq.prototype.setup = function(c){ if(this.mq.setup) return; this.mq.setup = this; var s, w, cObj = this, exit = 10000; if(this.c.style.height === 'auto') this.c.style.height = this.m.offsetHeight + 4 + 'px'; this.c.appendChild(this.m.cloneNode(true)); this.m = [this.m, this.m.nextSibling]; if(this.mq.mouse === 'cursor driven'){ this.r = this.mq.neutral || 16; this.sinc = this.mq.inc; this.c.onmousemove = function(e){cObj.mq.stopped = false; cObj.directspeed(e)}; if(this.mq.moveatleast){ this.mq.inc = this.mq.moveatleast; if(this.mq.savedirection){ if(this.mq.savedirection === 'reverse'){ this.c.onmouseout = function(e){ if(cObj.contains(e)) return; cObj.mq.inc = cObj.mq.moveatleast; cObj.mq.direction = cObj.mq.direction === 'right'? 'left' : 'right';}; } else { this.mq.savedirection = this.mq.direction; this.c.onmouseout = function(e){ if(cObj.contains(e)) return; cObj.mq.inc = cObj.mq.moveatleast; cObj.mq.direction = cObj.mq.savedirection;}; } } else this.c.onmouseout = function(e){if(!cObj.contains(e)) cObj.mq.inc = cObj.mq.moveatleast;}; } else this.c.onmouseout = function(e){if(!cObj.contains(e)) cObj.slowdeath();}; } this.w = this.m[0].offsetWidth; this.m[0].style.left = 0; this.c.id = 'marq_kill_marg_bord'; this.m[0].style.top = this.m[1].style.top = Math.floor((this.c.offsetHeight - this.m[0].offsetHeight) / 2 - oldie) + 'px'; this.c.id = ''; this.c.removeAttribute('id', 0); this.m[1].style.left = this.w + 'px'; s = this.mq.moveatleast? Math.max(this.mq.moveatleast, this.sinc) : (this.sinc || this.mq.inc); while(this.c.offsetWidth > this.w - s && --exit){ w = isNaN(this.cw[0])? this.w - s : --this.cw[0]; if(w < 1 || this.w < Math.max(1, s)){break;} this.c.style.width = isNaN(this.cw[0])? this.w - s + 'px' : --this.cw[0] + this.cw[1]; } this.c.style.visibility = 'visible'; this.runit(); } Marq.prototype.slowdeath = function(){ var cObj = this; if(this.mq.inc){ this.mq.inc -= 1; this.timer = setTimeout(function(){cObj.slowdeath();}, 100); } } Marq.prototype.runit = function(){ var cObj = this, d = this.mq.direction === 'right'? 1 : -1; if(this.mq.stopped || this.mq.stopMarquee){ setTimeout(function(){cObj.runit();}, 300); return; } if(this.mq.mouse != 'cursor driven') this.mq.inc = Math.max(1, this.mq.inc); if(d * parseInt(this.m[0].style.left) >= this.w) this.m[0].style.left = parseInt(this.m[1].style.left) - d * this.w + 'px'; if(d * parseInt(this.m[1].style.left) >= this.w) this.m[1].style.left = parseInt(this.m[0].style.left) - d * this.w + 'px'; this.m[0].style.left = parseInt(this.m[0].style.left) + d * this.mq.inc + 'px'; this.m[1].style.left = parseInt(this.m[1].style.left) + d * this.mq.inc + 'px'; setTimeout(function(){cObj.runit();}, 30 + (this.mq.addDelay || 0)); } Marq.prototype.directspeed = function(e){ e = e || window.event; if(this.timer) clearTimeout(this.timer); var c = this.c, w = c.offsetWidth, l = c.offsetLeft, mp = (typeof e.pageX === 'number'? e.pageX : e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft) - l, lb = (w - this.r) / 2, rb = (w + this.r) / 2; while((c = c.offsetParent)) mp -= c.offsetLeft; this.mq.direction = mp > rb? 'left' : 'right'; this.mq.inc = Math.round((mp > rb? (mp - rb) : mp < lb? (lb - mp) : 0) / lb * this.sinc); } Marq.prototype.contains = function(e){ if(e && e.relatedTarget){var c = e.relatedTarget; if(c === this.c) return true; while ((c = c.parentNode)) if(c === this.c) return true;} return false; } function resize(){ for(var s, w, m, i = 0; i < marqueeInit.ar.length; ++i){ if(marqueeInit.ar[i] && marqueeInit.ar[i].setup){ m = marqueeInit.ar[i].setup; s = m.mq.moveatleast? Math.max(m.mq.moveatleast, m.sinc) : (m.sinc || m.mq.inc); m.c.style.width = m.mq.style.width; m.cw[0] = m.cw.length > 1? parseInt(m.mq.style.width) : 'a'; while(m.c.offsetWidth > m.w - s){ w = isNaN(m.cw[0])? m.w - s : --m.cw[0]; if(w < 1){break;} m.c.style.width = isNaN(m.cw[0])? m.w - s + 'px' : --m.cw[0] + m.cw[1]; } } } } if (window.addEventListener) window.addEventListener('resize', resize, false); else if (window.attachEvent) window.attachEvent('onresize', resize); })(); /* Text and/or Image Crawler Script v1.5 (c)2009-2011 John Davenport Scheuer as first seen in http://www.dynamicdrive.com/forums/ username: jscheuer1 - This Notice Must Remain for Legal Use updated: 4/2011 for random order option, more (see below) */ </script> </head> <body> <font color="white" face="arial" size="2" background="#0066CC"> <div class="marquee" id="mycrawler" align="left"> 2/21/12 Today is testing the marquee. This will be used for announcements. Stay tuned!!!                         </div></font> <script type="text/javascript"> marqueeInit({ uniqueid: 'mycrawler', style: { 'padding': '1px', 'width': '1000px', //change to 1000 for normal, change to 0 for off 'background': '#0066CC', 'border': '0px solid black' }, inc: 1, //speed - pixel increment for each iteration of this marquee's movement mouse: 'false', //mouseover behavior ('pause' 'cursor driven' or false) moveatleast: 1, neutral: 150, savedirection: true }); </script> </body> </html> I am using a Theme Tester on my site so normal users can not see the changes being made. If you can help me, please send me a PM & I will give you a temporary login so you can login & see the new site, and the issue I am having. Basically, I am trying to get this http://flowplayer.org/tools/demos/sc.../navigator.htm scroller to work, but it is not happening at all. Not sure what is going on. Please advise. Thanks! |