JavaScript - Simple Content Displaying Script Not Working
Hi, I'm new to Javascript, so bear with me.
I'm trying to use a script that replaces the contents of a div, based on div id's. I've gotten it to work how I want he http://www.sixnations.be/home1.html But can't get it to work here, and I'm not sure why: http://www.sixnations.be/menu.html Relevent code, Javascript: Code: function changeMenu(obj) { if (obj == 'food') { //alert('food'); var fd = document.getElementById('food'); fd.style.display = 'inline'; var fdi = document.getElementById('foodImages'); fdi.style.display = 'inline'; var dr = document.getElementById('drink'); dr.style.display = 'none'; var dri = document.getElementById('drinkImages'); dri.style.display = 'none'; } else if (obj == 'drink') { //alert('drink'); var fd = document.getElementById('food'); fd.style.display = 'none'; var fdi = document.getElementById('foodImages'); fdi.style.display = 'none'; var dr = document.getElementById('drink'); dr.style.display = 'inline'; var dri = document.getElementById('drinkImages'); dri.style.display = 'inline'; } } HTML (the data's tabular, hence the tables): CSS: Code: /*-- MAIN CONTENT --*/ .maincont { width: 930px; margin: auto; margin-top: 10px; overflow: auto; } .backcont { position: relative; width: 620px; margin-right: 296px; } .backrightcont { float: right; width: 296px; } .backtop, #info_En, #info_Fr, #info_It, #drink, #food, .backrighttop { background-image: url(../sixnations_images/backtop.png); background-repeat: repeat-x; background-position: bottom; border-right: 1px solid #21201C; border-left: 1px solid #21201C; width: 100%; height: 57px; text-align: center; } .backbottom { background-image: url(../sixnations_images/backbottom.png); } #info_En, #info_Fr, #info_It, #food, #drink { background-image: url(../sixnations_images/contentback4.png); background-repeat: repeat; padding-bottom: 30px; text-align: left; height: auto; } .backright, .backrighttop, .backrightbottom { width: 100%; } .backright { background-image: url(../sixnations_images/backright.png); } .backrighttop { background-image: url(../sixnations_images/backtop2.png); background-position: top; border: 0; } .backrightbottom { height: 50px; background-image: url(../sixnations_images/backrightbottom.png); border: 0; } .backrighttop h1, .backright h1 { font-family: 'Cambria', Palatino, Georgia, serif; font-size: 1.6em; color: #eee; line-height: 70px; text-align: center; } .backright h1 { width: 95%; line-height: normal; border-top:1px dashed #333; padding-top: 15px; } #noborder { border:0; } .twitter { margin-left: 15px; } #info_Fr, #info_It, #drink { display: none; } .lang, #info_En p, #info_En h1, #info_Fr p, #info_Fr h1, #info_It p, #info_It h1, #food h1, #food p, #drink h1, #drink p { width: 71%; margin: auto; } #info_En h1, #info_Fr h1, #info_It h1, #food h1, #drink h1 { font-family: 'GothamBook','Cambria', Georgia, serif; font-size: 2.5em; color: #000; padding-bottom: 10px; padding-top: 20px; margin-bottom: 15px; font-variant: small-caps; letter-spacing:.1em; text-align: center; border-bottom: 1px dashed #777; } .lang { margin-top: 35px; padding-top: 5px; border-top: 1px dashed #777; font-size: 1em; font-variant: small-caps; text-align: right; color: #777; } .lang a:hover { background-color: #777; color: #eee; } /*-- MAIN CONTENT -- SPORTS ON TV / FOOD & DRINK --*/ table.sports, table.menu1 { width: 90%; margin: auto; } table.sports thead td, table.menu1 thead td { font-size: 1.3em; font-variant: small-caps; color: #777; border-bottom: 1px dotted #999; width: 100%; padding-top: 20px; } table.sports tr, table.menu1 tr { border-bottom: 1px dotted #999; } table.menu1 tr { border: 0; } table.sports td { padding: 7px; } table.menu1 td { border:0; padding: 8px; } table.sports td.foot, table.sports td.rugby { background-image: url(../sixnations_images/ball1.png); background-repeat: no-repeat; background-position: bottom left; padding-left: 35px; } table.sports td.foot { background-image: url(../sixnations_images/ball2.png); } table.menu1 td.desc { color: #888; font-style: italic; padding-top: 0px; font-size: .9em; } Any ideas? Similar TutorialsYou've all seen it before banner codes/rss feed displayers/twitter feeds/etc etc all you do is copy and paste a <script src="http://somewebserver/display.js"></script> somewhere on your website and it retrieves the html from the remote server and displays it on your site. My question as simple as it sounds is how the hell does this stuff work? I have a back end php page that pulls the required information from my DB based off a userid passed to it ie: mywebserver.com/display.php?id=xxxx Is the javascript just a simple ajax call to my php page passing straight on the userid passed to it or is there something more complex to it? I was always under the impression you couldn't do remote ajax calls to a page on a different server, which if I get this right a script off my server included on another domain becomes a member script of that domain and not my own? I am one problem. When i click a link a some information in html is to be displayed on the screen. I have written code for that. But before i click the link i am able to display the content. Please look into my code and give some suggestions: <html> <head> </head> <body> <center> <table> <tr> <td> <a href="javascript:Chg1()">Add Required (Features)</a> </td> <td> <a href="javascript:chg2()">Add via Search</a> </td> <td> <a href="javascript:Chg3()">Add via List</a> </td> </tr> </table> </center> function chg2() { document.write(<b> Type Model Feature Relationship Search and Add </b>);s <table> <tr> <td> Type<input type="text" id="type" name="type" value=""> </td> <td> Document Number<input type="text" id="doc" name="doc" value=""> </td> </tr> <tr> <td> Model<input type="text" id="model" name="model" value=""> </td> <td> Promoted<input type="text" id="promoted" name="promoted" value=""> </td> </tr> <tr> <td> Feature<input type="text" id="feature" name="feature" value=""> </td> </tr> </table> } </script> </body> I am pretty sure this is a javascript function. I want it where when a person chooses an option in a select box, it displays content. Here is the page it'd be on. http://www.rodgame.org/register.html So for Class: once they select something, in the black area in the middle bottom, it'd show a description of that class. How would I do something like this? Hi all, I'm not sure if this is a Javascript question or PHP, so if it needs to be moved can an admin please do so... Anyway, basically I have the following code: Code: <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">View Availability</a> This pops up a divs with a black alpha background, so that it appears the new content is displaying over the top of the current content. This all works fine, however the content I am displaying in the top level div is (or should be) dynamic. In order for the content to be useful I need to grab the id. Normally I would simply do this: Code: <a href = "url.php?uniqueidentifier=<?php echo $row['id'];?>" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">View Availability</a> However what happens in this instance is that the page loads with the javascript and the id in the url but it then disappears... Has anyone got any ideas on how I might be able to get around this? Many thanks, Greens85 I have a site that can be downloaded and run on a closed network (not needing an active Internet connection). I'd like a page that displays live data to a user with Internet connectivity (I can do this) but display "canned" data when the user is without an internet connection...and this difference in page display is transparent to the user. I know this can be done with php but the user without Internet connectivity will likely not be able to run php locally so the page must be an .htm file. I there a javascript somewhere that does this?Any help is greatly appreciated.
I'm using the script below in a custom HTML to generate a random line of text (not with the text shown here). This works fine BUT; I want it to go randomly through the WHOLE list without repeating lines that already have been printed. As it is now, a line of text might be printed several times in a row, which is a little annoying. I'm using a refresh button for generating a new line of text. Alternatively, How can I just make it display in the order shown and just re-arrange the content so it seems random to the user? Random would the best though... Any ideas?? : ) Code: <script language="JavaScript"> <!-- var r_text = new Array (); r_text[0] = "All the leaves are brown"; r_text[1] = "And the sky is grey"; r_text[2] = "I've been for a walk"; r_text[3] = "On a winter's day"; r_text[4] = "I'd be safe and warm"; r_text[5] = "If I was in L.A."; r_text[6] = "California dreaming, On such a winter's day"; var i = Math.floor(7*Math.random()) document.write(r_text[i]); //--> </script> Hi, I'm using javascript in addition to a web service (BTBuckets) to display different content to visitors based on actions they take on my site. The javascript is working fine, but I noticed that if I simulate BTBuckets being disabled using Firefox Adblock none of the content shows up. So in the off chance of the service going offline it'll leave some pretty funky holes in the my content. I tried <noscript> tags which works with javascript off, but the content is still blank when I disable BTBuckets. I'm wondering if there's a way to display the default content if the service is unavailable? Here's the code I'm using: In the head: Code: <script type="text/javascript"> //<![CDATA[[ $BTB={s:XXXXX}; $BTB.jsh="http://static.btbuckets.com/bt.js"; //]]> </script> <script type="text/javascript"> document.write(unescape("%3Cscript src='" + $BTB.jsh.replace(/(https?:)/i,document.location.protocol) + "' type='text/javascript'%3E%3C/script%3E")); </script> The code in the body used to replace an image depending on visitor behavior: Code: <script type="text/javascript"> var _t = ""; if ($BTB.clusters["ppc_visitors"]) { _t = "\"images/top-photo-tracking-number.jpg\" alt=\"Call Toll-Free: 1-800-XXX-XXXX\">"; } else { _t = "\"images/top-photo.jpg\" alt=\"Call Toll-Free: 1-800-XXX-XXXX\">"; } document.write('<img src= ' + _t ); </script> <noscript><img src="images/top-photo.jpg" alt="Call Toll-Free: 1-800-XXX-XXXX"></noscript> Hello, I have an html script and a .php script. The .php requests a random word from a table of words in a mysql database. I wrote a html form to display the requested word in a text box. Here is my html file: Code: <html> <body> <script type="text/javascript"> function myfunction() { var xmlhttp; if(window.XMLHttpRequest) { xmlhttp= newHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { document.myLingo.word.value=xmlhttp.responseText; } } xmlhttp.open("GET", "get_Word.php",true); xmlhttp.send(null); } </script> <form name="myLingo"> <input type="button" name="button" value="New Word" onClick="myFunction();" /> <input type="text" name="word" /> </form> </body> </html> and here is my .php script: Code: <?php $con=mysql_connect('localhost', 'xxxx', 'xxxx'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("my_lingo", $con); $sql=mysql_query("SELECT `word` FROM `words` ORDER BY RAND()") or trigger_error('Error: ' .mysql_error()); $word=mysql_fetch_array($sql); echo $word[0]; mysql_close($con); ?> When I run this in Internet Explorer; I get a error that is asking for an object on line 32 which is the line that has my button in the javascript. When i run it in firefox, I don't receive an error, but the page still does nothing. Any suggestions? The main function of the page is that, when I click the button, it's supposed to return me a random word from the .php script Thanks, jcjst21 Can someone tel me the code to put a dropdown box showing default values as shown below using script ..i,e by enclosing them in document.write in script <CODE> <SELECT NAME="choice" > <OPTION VALUE="1">one </OPTION > <OPTION VALUE="2">two </OPTION > <OPTION SELECTED VALUE=" 5 "> 5 </OPTION> </SELECT> </CODE> Hello all, i am new to this forum.. i am validating a form and displaying results.. but, instead of displaying the result in popup(alert), i need to display it as a text that disappears after a few seconds.. Code: function valtext() { if(document.getElementById("functional").value == "") { document.getElementById("label").innerHTML=message; startTimer(); } } function hideMessage() { document.getElementById("label").style.display="none"; clearTimeout(tim); } function startTimer() { tim = setTimeout("hideMessage()",3000); } i did it using the above code.. but my problem is, i cant check it the second time, without reloading the page.. how to do it without refreshing the page and i want to add a bg color to that warning.. how to do that.. and, is there anyother way of doing it? any help is much appreciated.. and thanks I would like to mention: I DON'T KNOW MUCH (ANYTHING) ABOUT JAVASCRIPT I am using this script to reload my minicart every 1 second but it doesn't work in IE. I don't want to use php (because the e-commerce site I am using doesn't allow php). Code: <script type="text/javascript"> function cartRefresh() { $("#minicart").load(location.href+" #minicart>*",""); $("#sliderContent").load(location.href+" #sliderContent>*",""); } setInterval(function() { cartRefresh(); }, 1000); </script> Can anyone help me out with either a new code or make this workable with IE? thnx a bunch! Hi I am a new user to JS, and I have a problem he I have some JS code to work on a data set with file name "data.txt" in the header section of an HTML page. Code: <script type="text/javascript" src="data.txt"></script> What I am trying to do is to ask a user to input a different file name, then update the file name in the <script> tag, for example, to Code: <script type="text/javascript" src="new_data.txt"></script> But I don't know how to update the file name. Any help will be appreciated. I am using a content revealing script, it is functioning pefectly except for one small issue. I have the content being shown on mouseover, but I would not like it to display right away - i need a delay on the mouseover. meaning that only if mouseover for a set time (say 3000ms.) it will show. the purpose of this is to not accidently open the content when travelling with the mouse around the page.. the content will show ONLY if the user wants it to open it ie. holding the mouse on there for a few seconds. The script I am using is from featured content slider. contentslider.js I marked areas of interest in the code in RED Code: //** Featured Content Slider script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com. //** May 2nd, 08'- Script rewritten and updated to 2.0. //** June 12th, 08'- Script updated to v 2.3, which adds the following features: //1) Changed behavior of script to actually collapse the previous content when the active one is shown, instead of just tucking it underneath the later. //2) Added setting to reveal a content either via "click" or "mouseover" of pagination links (default is former). //3) Added public function for jumping to a particular slide within a Featured Content instance using an arbitrary link, for example. //** July 11th, 08'- Script updated to v 2.4: //1) Added ability to select a particular slide when the page first loads using a URL parameter (ie: mypage.htm?myslider=4 to select 4th slide in "myslider") //2) Fixed bug where the first slide disappears when the mouse clicks or mouses over it when page first loads. //** Dec 20th, 12'- v 2.41: Fixed bug with slider failing to load if the same script is used on different pages with different # of contents var featuredcontentslider={ //3 variables below you can customize if desired: ajaxloadingmsg: '<div style="margin: 20px 0 0 20px"><img src="loading.gif" /> Fetching slider Contents. Please wait...</div>', bustajaxcache: true, //bust caching of external ajax page after 1st request? enablepersist: true, //persist to last content viewed when returning to page? settingcaches: {}, //object to cache "setting" object of each script instance jumpTo:function(fcsid, pagenumber){ //public function to go to a slide manually. this.turnpage(this.settingcaches[fcsid], pagenumber) }, ajaxconnect:function(setting){ var page_request = false if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else return false var pageurl=setting.contentsource[1] page_request.onreadystatechange=function(){ featuredcontentslider.ajaxpopulate(page_request, setting) } document.getElementById(setting.id).innerHTML=this.ajaxloadingmsg var bustcache=(!this.bustajaxcache)? "" : (pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', pageurl+bustcache, true) page_request.send(null) }, ajaxpopulate:function(page_request, setting){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){ document.getElementById(setting.id).innerHTML=page_request.responseText this.buildpaginate(setting) } }, buildcontentdivs:function(setting){ var alldivs=document.getElementById(setting.id).getElementsByTagName("div") for (var i=0; i<alldivs.length; i++){ if (this.css(alldivs[i], "contentdiv", "check")){ //check for DIVs with class "contentdiv" setting.contentdivs.push(alldivs[i]) alldivs[i].style.display="none" //collapse all content DIVs to begin with } } if (setting.currentpage > setting.contentdivs.length){ setting.currentpage=1 setting.prevpage=1 } }, buildpaginate:function(setting){ this.buildcontentdivs(setting) var sliderdiv=document.getElementById(setting.id) var pdiv=document.getElementById("paginate-"+setting.id) var phtml="" var toc=setting.toc var nextprev=setting.nextprev if (typeof toc=="string" && toc!="markup" || typeof toc=="object"){ for (var i=1; i<=setting.contentdivs.length; i++){ phtml+='<a href="#'+i+'" class="toc">'+(typeof toc=="string"? toc.replace(/#increment/, i) : toc[i-1])+'</a> ' } phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '') pdiv.innerHTML=phtml } var pdivlinks=pdiv.getElementsByTagName("a") var toclinkscount=0 //var to keep track of actual # of toc links for (var i=0; i<pdivlinks.length; i++){ if (this.css(pdivlinks[i], "toc", "check")){ if (toclinkscount>setting.contentdivs.length-1){ //if this toc link is out of range (user defined more toc links then there are contents) pdivlinks[i].style.display="none" //hide this toc link continue } pdivlinks[i].setAttribute("rel", ++toclinkscount) //store page number inside toc link pdivlinks[i][setting.revealtype]=function(){ featuredcontentslider.turnpage(setting, this.getAttribute("rel")) return false } setting.toclinks.push(pdivlinks[i]) } else if (this.css(pdivlinks[i], "prev", "check") || this.css(pdivlinks[i], "next", "check")){ //check for links with class "prev" or "next" pdivlinks[i].onclick=function(){ featuredcontentslider.turnpage(setting, this.className) return false } } } this.turnpage(setting, setting.currentpage, true) if (setting.autorotate[0]){ //if auto rotate enabled pdiv[setting.revealtype]=function(){ featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id]) } sliderdiv["onclick"]=function(){ //stop content slider when slides themselves are clicked on featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id]) } setting.autorotate[1]=setting.autorotate[1]+(1/setting.enablefade[1]*50) //add time to run fade animation (roughly) to delay between rotation this.autorotate(setting) } }, urlparamselect:function(fcsid){ var result=window.location.search.match(new RegExp(fcsid+"=(\\d+)", "i")) //check for "?featuredcontentsliderid=2" in URL return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index }, turnpage:function(setting, thepage, autocall){ var currentpage=setting.currentpage //current page # before change var totalpages=setting.contentdivs.length var turntopage=(/prev/i.test(thepage))? currentpage-1 : (/next/i.test(thepage))? currentpage+1 : parseInt(thepage) turntopage=(turntopage<1)? totalpages : (turntopage>totalpages)? 1 : turntopage //test for out of bound and adjust if (turntopage==setting.currentpage && typeof autocall=="undefined") //if a pagination link is clicked on repeatedly return setting.currentpage=turntopage setting.contentdivs[turntopage-1].style.zIndex=++setting.topzindex this.cleartimer(setting, window["fcsfade"+setting.id]) setting.cacheprevpage=setting.prevpage if (setting.enablefade[0]==true){ setting.curopacity=0 this.fadeup(setting) } if (setting.enablefade[0]==false){ //if fade is disabled, fire onChange event immediately (verus after fade is complete) setting.contentdivs[setting.prevpage-1].style.display="none" //collapse last content div shown (it was set to "block") setting.onChange(setting.prevpage, setting.currentpage) } setting.contentdivs[turntopage-1].style.visibility="visible" setting.contentdivs[turntopage-1].style.display="block" if (setting.prevpage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) this.css(setting.toclinks[setting.prevpage-1], "selected", "remove") if (turntopage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) this.css(setting.toclinks[turntopage-1], "selected", "add") setting.prevpage=turntopage if (this.enablepersist) this.setCookie("fcspersist"+setting.id, turntopage) }, setopacity:function(setting, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between) var targetobject=setting.contentdivs[setting.currentpage-1] if (targetobject.filters && targetobject.filters[0]){ //IE syntax if (typeof targetobject.filters[0].opacity=="number") //IE6 targetobject.filters[0].opacity=value*100 else //IE 5.5 targetobject.style.filter="alpha(opacity="+value*100+")" } else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax targetobject.style.MozOpacity=value else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax targetobject.style.opacity=value setting.curopacity=value }, fadeup:function(setting){ if (setting.curopacity<1){ this.setopacity(setting, setting.curopacity+setting.enablefade[1]) window["fcsfade"+setting.id]=setTimeout(function(){featuredcontentslider.fadeup(setting)}, 50) } else{ //when fade is complete if (setting.cacheprevpage!=setting.currentpage) //if previous content isn't the same as the current shown div (happens the first time the page loads/ script is run) setting.contentdivs[setting.cacheprevpage-1].style.display="none" //collapse last content div shown (it was set to "block") setting.onChange(setting.cacheprevpage, setting.currentpage) } }, cleartimer:function(setting, timervar){ if (typeof timervar!="undefined"){ clearTimeout(timervar) clearInterval(timervar) if (setting.cacheprevpage!=setting.currentpage){ //if previous content isn't the same as the current shown div setting.contentdivs[setting.cacheprevpage-1].style.display="none" } } }, css:function(el, targetclass, action){ var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig") if (action=="check") return needle.test(el.className) else if (action=="remove") el.className=el.className.replace(needle, "") else if (action=="add") el.className+=" "+targetclass }, autorotate:function(setting){ window["fcsautorun"+setting.id]=setInterval(function(){featuredcontentslider.turnpage(setting, "next")}, setting.autorotate[1]) }, 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 }, setCookie:function(name, value){ document.cookie = name+"="+value }, init:function(setting){ var persistedpage=this.getCookie("fcspersist"+setting.id) || 1 var urlselectedpage=this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index this.settingcaches[setting.id]=setting //cache "setting" object setting.contentdivs=[] setting.toclinks=[] setting.topzindex=0 setting.currentpage=urlselectedpage || ((this.enablepersist)? persistedpage : 1) setting.prevpage=setting.currentpage setting.revealtype="on"+(setting.revealtype || "click") setting.curopacity=0 setting.onChange=setting.onChange || function(){} if (setting.contentsource[0]=="inline") this.buildpaginate(setting) if (setting.contentsource[0]=="ajax") this.ajaxconnect(setting) } } This is the code you embed in the webpage: Code: <h2>Example 1</h2> <!--Inner content DIVs should always carry "contentdiv" CSS class--> <!--Pagination DIV should always carry "paginate-SLIDERID" CSS class--> <div id="slider1" class="sliderwrapper"> <div class="contentdiv"> Content 1 Here. <br /> <p></p><a href="javascript:featuredcontentslider.jumpTo('slider1', 3)">Go to 3rd slide</a></p> </div> <div class="contentdiv"> Content 2 Here. </div> <div class="contentdiv"> Content 3 Here. </div> </div> <div id="paginate-slider1" class="pagination"> </div> <script type="text/javascript"> featuredcontentslider.init({ id: "slider1", //id of main slider DIV contentsource: ["inline", ""], //Valid values: ["inline", ""] or ["ajax", "path_to_file"] toc: "#increment", //Valid values: "#increment", "markup", ["label1", "label2", etc] nextprev: ["Previous", "Next"], //labels for "prev" and "next" links. Set to "" to hide. revealtype: "mouseover", //Behavior of pagination links to reveal the slides: "click" or "mouseover" enablefade: [true, 0.2], //[true/false, fadedegree] autorotate: [false, 3000], //[true/false, pausetime] onChange: function(previndex, curindex){ //event handler fired whenever script changes slide //previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc) //curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc) } }) </script> Hello, Well I have script that claims that it loads the flash content while it is showing seconds or advertisement. So as I don't know about scripts I have no Idea if it actually do that or not as What I visually see is that it let flash content load once the seconds of disappears. So that's why I want an expert advice on it. And how the seconds of this script works Only if this script actually do what It claims, then I would like to know when does it send alert to load the content (as I would like to put the alert from the start) and how to show it for more or less seconds. Relevant Markup: Live Demo http://files.cryoffalcon.com/MyFootP...%20Loader.html What is the live demo made up of: Code: <div class="colorchooser"> <!--more--> <div class="displaygame_part"> <center> <div id="ads" class="ads"> <h1> ADVERTISEMENT</h1> <center> <script type="text/javascript"><!-- google_ad_client = "ca-pub-0726197409084548"; /* bloghutsgame */ google_ad_slot = "5324930917"; google_ad_width = 336; google_ad_height = 280; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></center> To skip it click <a href="javascript:ShowHide();">here</a> <script type="text/javascript"> window.onload = function() { startCountDown(8, 1000); } function startCountDown(i, p, f) { // store parameters var pause = p; var fn = f; // make reference to div var countDownObj = document.getElementById("countDown"); if (countDownObj == null) { return; } countDownObj.count = function(i) { // write out count countDownObj.innerHTML = i; if (i == 0) { // execute function fn(); // stop return; } setTimeout(function() { // repeat countDownObj.count(i - 1); }, pause ); } // set it going countDownObj.count(i); } </script> <center> <img border="0" height="117" width="201" src="@---put the link of the image of fancy pants(its the loader)---@" /> </center> <div id="countDown" style="display: inline;"> </div> seconds for the game to load... </div> <div id="gamecontent" style="visibility:hidden; display:none"> <div class="gofulldear"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%"> <param name="movie" value="http://games.balloontowerdefense.net/b/balloon_tower_defense_4_expansion.swf"> <param name="quality" value="high"> <param name="allowNetworking" value="internal"> <embed src="http://games.balloontowerdefense.net/b/balloon_tower_defense_4_expansion.swf" width="100%" height="100%" align="center" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allownetworking="internal"></embed> </object> </div> </div> <script type="text/javascript"> function turn_vis_on(id) { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById(id).style.display = 'inline'; obj = document.getElementById(id); obj.style.visibility = "visible"; } } function turn_vis_off(id){ if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById(id).style.display = 'none'; obj = document.getElementById(id); obj.style.visibility = "hidden"; } } function ShowHide() { turn_vis_off("ads"); turn_vis_on("gamecontent"); // alert('4sec!'); } document.getElementById("ads").style.zIndex = 100; timeoutID = setTimeout(ShowHide, 15000); </script> </center></div> </div> Note: It is game so there can be sound or music in it./ For any more information requirement please let me know I will edit it, so to make it as relevant as possible^^. Hello Friend, I am using a javascript code installed with Dreamweaver for this page: http://www.alpinelakesair.com/newsite/charters.php When you open the page, (the script element is on the right), the first tab is already open. I would like none of the tabs to be open, so that you have to first click on a tab to open it. Also, when you start clicking on the tabs, a blue focus ring surrounds the active elements. I do not like the blue focus ring. Finally, you may notice that when you click on the tabs there is a slight jumping action that takes place among the tabs, a slight skip before the tab starts sliding up. So my questions a 1. how to not have any tabs open from the start. 2. how to get rid of the blue focus ring. (if you are seeing it) 3. not a big deal, but it would be nice to get rid of that skipping action so the sliding elements moved smoothly. My HTML is: Code: <div id="Accordion1" class="Accordion" tabindex="0"> <div class="AccordionPanel"> <div class="AccordionPanelTab">DHC-3 Turbo Otter Charter Rate</div> <div class="AccordionPanelContent"> <ul> <li>Fuel included</li> <li>Rate based out of Smithers, B.C.</li> <li>For Rules, Rates, & Charges please see attached <a href="" target="_blank">Domestic Tariff PDF</a></li> </ul> </div> </div> <div class="AccordionPanel"> <div class="AccordionPanelTab">EADS Wilga 2000 Charter Rate</div> <div class="AccordionPanelContent"> <ul> <li>Fuel included</li> <li>Rate based out of Smithers, B.C.</li> <li>For Rules, Rates, & Charges please see attached <a href="" target="_blank">Domestic Tariff PDF</a></li> </ul> </div> </div> <div class="AccordionPanel"> <div class="AccordionPanelTab">Cessna 185 Charter Rate</div> <div class="AccordionPanelContent"> <ul> <li>Fuel included</li> <li>Rate based out of Smithers, B.C.</li> <li>For Rules, Rates, & Charges please see attached <a href="" target="_blank">Domestic Tariff PDF</a></li> </ul> </div> </div> </div> My CSS is: Code: .Accordion { overflow: hidden; width: 250px; height: 250px; } .AccordionPanel { margin: 0px; padding: 0px; } .AccordionPanelTab { background-color: #000; border: thin solid #363535; margin: 0px; margin-bottom: 5px; padding: 5px 10px; cursor: pointer; font-size: 0.9em; text-transform: uppercase; -moz-user-select: none; -khtml-user-select: none; } .AccordionPanelContent { overflow: auto; margin: 0px; margin-bottom: 5px; padding: 5px 10px; border: thin solid #363535; } .AccordionPanelOpen .AccordionPanelTab { background-color: #7f0202; margin-bottom: 0; } .AccordionPanelTabHover { background-color: #7f0202; } .AccordionPanelOpen .AccordionPanelTabHover { color: #555555; } .AccordionFocused .AccordionPanelTab { } .AccordionFocused .AccordionPanelOpen .AccordionPanelTab { } And my JS is: Code: var Spry; if (!Spry) Spry = {}; if (!Spry.Widget) Spry.Widget = {}; Spry.Widget.Accordion = function(element, opts) { this.element = this.getElement(element); this.defaultPanel = 0; this.hoverClass = "AccordionPanelTabHover"; this.openClass = "AccordionPanelOpen"; this.closedClass = "AccordionPanelClosed"; this.focusedClass = "AccordionFocused"; this.enableAnimation = true; this.enableKeyboardNavigation = true; this.currentPanel = null; this.animator = null; this.hasFocus = null; this.previousPanelKeyCode = Spry.Widget.Accordion.KEY_UP; this.nextPanelKeyCode = Spry.Widget.Accordion.KEY_DOWN; this.useFixedPanelHeights = true; this.fixedPanelHeight = 0; Spry.Widget.Accordion.setOptions(this, opts, true); this.attachBehaviors(); }; Spry.Widget.Accordion.prototype.getElement = function(ele) { if (ele && typeof ele == "string") return document.getElementById(ele); return ele; }; Spry.Widget.Accordion.prototype.addClassName = function(ele, className) { if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1)) return; ele.className += (ele.className ? " " : "") + className; }; Spry.Widget.Accordion.prototype.removeClassName = function(ele, className) { if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1)) return; ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), ""); }; Spry.Widget.Accordion.setOptions = function(obj, optionsObj, ignoreUndefinedProps) { if (!optionsObj) return; for (var optionName in optionsObj) { if (ignoreUndefinedProps && optionsObj[optionName] == undefined) continue; obj[optionName] = optionsObj[optionName]; } }; Spry.Widget.Accordion.prototype.onPanelTabMouseOver = function(e, panel) { if (panel) this.addClassName(this.getPanelTab(panel), this.hoverClass); return false; }; Spry.Widget.Accordion.prototype.onPanelTabMouseOut = function(e, panel) { if (panel) this.removeClassName(this.getPanelTab(panel), this.hoverClass); return false; }; Spry.Widget.Accordion.prototype.openPanel = function(elementOrIndex) { var panelA = this.currentPanel; var panelB; if (typeof elementOrIndex == "number") panelB = this.getPanels()[elementOrIndex]; else panelB = this.getElement(elementOrIndex); if (!panelB || panelA == panelB) return null; var contentA = panelA ? this.getPanelContent(panelA) : null; var contentB = this.getPanelContent(panelB); if (!contentB) return null; if (this.useFixedPanelHeights && !this.fixedPanelHeight) this.fixedPanelHeight = (contentA.offsetHeight) ? contentA.offsetHeight : contentA.scrollHeight; if (this.enableAnimation) { if (this.animator) this.animator.stop(); this.animator = new Spry.Widget.Accordion.PanelAnimator(this, panelB, { duration: this.duration, fps: this.fps, transition: this.transition }); this.animator.start(); } else { if(contentA) { contentA.style.display = "none"; contentA.style.height = "0px"; } contentB.style.display = "block"; contentB.style.height = this.useFixedPanelHeights ? this.fixedPanelHeight + "px" : "auto"; } if(panelA) { this.removeClassName(panelA, this.openClass); this.addClassName(panelA, this.closedClass); } this.removeClassName(panelB, this.closedClass); this.addClassName(panelB, this.openClass); this.currentPanel = panelB; return panelB; }; Spry.Widget.Accordion.prototype.closePanel = function() { // The accordion can only ever have one panel open at any // give time, so this method only closes the current panel. // If the accordion is in fixed panel heights mode, this // method does nothing. if (!this.useFixedPanelHeights && this.currentPanel) { var panel = this.currentPanel; var content = this.getPanelContent(panel); if (content) { if (this.enableAnimation) { if (this.animator) this.animator.stop(); this.animator = new Spry.Widget.Accordion.PanelAnimator(this, null, { duration: this.duration, fps: this.fps, transition: this.transition }); this.animator.start(); } else { content.style.display = "none"; content.style.height = "0px"; } } this.removeClassName(panel, this.openClass); this.addClassName(panel, this.closedClass); this.currentPanel = null; } }; Spry.Widget.Accordion.prototype.openNextPanel = function() { return this.openPanel(this.getCurrentPanelIndex() + 1); }; Spry.Widget.Accordion.prototype.openPreviousPanel = function() { return this.openPanel(this.getCurrentPanelIndex() - 1); }; Spry.Widget.Accordion.prototype.openFirstPanel = function() { return this.openPanel(0); }; Spry.Widget.Accordion.prototype.openLastPanel = function() { var panels = this.getPanels(); return this.openPanel(panels[panels.length - 1]); }; Spry.Widget.Accordion.prototype.onPanelTabClick = function(e, panel) { if (panel != this.currentPanel) this.openPanel(panel); else this.closePanel(); if (this.enableKeyboardNavigation) this.focus(); if (e.preventDefault) e.preventDefault(); else e.returnValue = false; if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; return false; }; Spry.Widget.Accordion.prototype.onFocus = function(e) { this.hasFocus = true; this.addClassName(this.element, this.focusedClass); return false; }; Spry.Widget.Accordion.prototype.onBlur = function(e) { this.hasFocus = false; this.removeClassName(this.element, this.focusedClass); return false; }; Spry.Widget.Accordion.KEY_UP = 38; Spry.Widget.Accordion.KEY_DOWN = 40; Spry.Widget.Accordion.prototype.onKeyDown = function(e) { var key = e.keyCode; if (!this.hasFocus || (key != this.previousPanelKeyCode && key != this.nextPanelKeyCode)) return true; var panels = this.getPanels(); if (!panels || panels.length < 1) return false; var currentPanel = this.currentPanel ? this.currentPanel : panels[0]; var nextPanel = (key == this.nextPanelKeyCode) ? currentPanel.nextSibling : currentPanel.previousSibling; while (nextPanel) { if (nextPanel.nodeType == 1 /* Node.ELEMENT_NODE */) break; nextPanel = (key == this.nextPanelKeyCode) ? nextPanel.nextSibling : nextPanel.previousSibling; } if (nextPanel && currentPanel != nextPanel) this.openPanel(nextPanel); if (e.preventDefault) e.preventDefault(); else e.returnValue = false; if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; return false; }; Spry.Widget.Accordion.prototype.attachPanelHandlers = function(panel) { if (!panel) return; var tab = this.getPanelTab(panel); if (tab) { var self = this; Spry.Widget.Accordion.addEventListener(tab, "click", function(e) { return self.onPanelTabClick(e, panel); }, false); Spry.Widget.Accordion.addEventListener(tab, "mouseover", function(e) { return self.onPanelTabMouseOver(e, panel); }, false); Spry.Widget.Accordion.addEventListener(tab, "mouseout", function(e) { return self.onPanelTabMouseOut(e, panel); }, false); } }; Spry.Widget.Accordion.addEventListener = function(element, eventType, handler, capture) { try { if (element.addEventListener) element.addEventListener(eventType, handler, capture); else if (element.attachEvent) element.attachEvent("on" + eventType, handler); } catch (e) {} }; Spry.Widget.Accordion.prototype.initPanel = function(panel, isDefault) { var content = this.getPanelContent(panel); if (isDefault) { this.currentPanel = panel; this.removeClassName(panel, this.closedClass); this.addClassName(panel, this.openClass); // Attempt to set up the height of the default panel. We don't want to // do any dynamic panel height calculations here because our accordion // or one of its parent containers may be display:none. if (content) { if (this.useFixedPanelHeights) { // We are in fixed panel height mode and the user passed in // a panel height for us to use. if (this.fixedPanelHeight) content.style.height = this.fixedPanelHeight + "px"; } else { // We are in variable panel height mode, but since we can't // calculate the panel height here, we just set the height to // auto so that it expands to show all of its content. content.style.height = "auto"; } } } else { this.removeClassName(panel, this.openClass); this.addClassName(panel, this.closedClass); if (content) { content.style.height = "0px"; content.style.display = "none"; } } this.attachPanelHandlers(panel); }; Spry.Widget.Accordion.prototype.attachBehaviors = function() { var panels = this.getPanels(); for (var i = 0; i < panels.length; i++) this.initPanel(panels[i], i == this.defaultPanel); // Advanced keyboard navigation requires the tabindex attribute // on the top-level element. this.enableKeyboardNavigation = (this.enableKeyboardNavigation && this.element.attributes.getNamedItem("tabindex")); if (this.enableKeyboardNavigation) { var self = this; Spry.Widget.Accordion.addEventListener(this.element, "focus", function(e) { return self.onFocus(e); }, false); Spry.Widget.Accordion.addEventListener(this.element, "blur", function(e) { return self.onBlur(e); }, false); Spry.Widget.Accordion.addEventListener(this.element, "keydown", function(e) { return self.onKeyDown(e); }, false); } }; Spry.Widget.Accordion.prototype.getPanels = function() { return this.getElementChildren(this.element); }; Spry.Widget.Accordion.prototype.getCurrentPanel = function() { return this.currentPanel; }; Spry.Widget.Accordion.prototype.getPanelIndex = function(panel) { var panels = this.getPanels(); for( var i = 0 ; i < panels.length; i++ ) { if( panel == panels[i] ) return i; } return -1; }; Spry.Widget.Accordion.prototype.getCurrentPanelIndex = function() { return this.getPanelIndex(this.currentPanel); }; Spry.Widget.Accordion.prototype.getPanelTab = function(panel) { if (!panel) return null; return this.getElementChildren(panel)[0]; }; Spry.Widget.Accordion.prototype.getPanelContent = function(panel) { if (!panel) return null; return this.getElementChildren(panel)[1]; }; Spry.Widget.Accordion.prototype.getElementChildren = function(element) { var children = []; var child = element.firstChild; while (child) { if (child.nodeType == 1 /* Node.ELEMENT_NODE */) children.push(child); child = child.nextSibling; } return children; }; Spry.Widget.Accordion.prototype.focus = function() { if (this.element && this.element.focus) this.element.focus(); }; Spry.Widget.Accordion.prototype.blur = function() { if (this.element && this.element.blur) this.element.blur(); }; ///////////////////////////////////////////////////// Spry.Widget.Accordion.PanelAnimator = function(accordion, panel, opts) { this.timer = null; this.interval = 0; this.fps = 60; this.duration = 500; this.startTime = 0; this.transition = Spry.Widget.Accordion.PanelAnimator.defaultTransition; this.onComplete = null; this.panel = panel; this.panelToOpen = accordion.getElement(panel); this.panelData = []; this.useFixedPanelHeights = accordion.useFixedPanelHeights; Spry.Widget.Accordion.setOptions(this, opts, true); this.interval = Math.floor(1000 / this.fps); // Set up the array of panels we want to animate. var panels = accordion.getPanels(); for (var i = 0; i < panels.length; i++) { var p = panels[i]; var c = accordion.getPanelContent(p); if (c) { var h = c.offsetHeight; if (h == undefined) h = 0; if (p == panel && h == 0) c.style.display = "block"; if (p == panel || h > 0) { var obj = new Object; obj.panel = p; obj.content = c; obj.fromHeight = h; obj.toHeight = (p == panel) ? (accordion.useFixedPanelHeights ? accordion.fixedPanelHeight : c.scrollHeight) : 0; obj.distance = obj.toHeight - obj.fromHeight; obj.overflow = c.style.overflow; this.panelData.push(obj); c.style.overflow = "hidden"; c.style.height = h + "px"; } } } }; Spry.Widget.Accordion.PanelAnimator.defaultTransition = function(time, begin, finish, duration) { time /= duration; return begin + ((2 - time) * time * finish); }; Spry.Widget.Accordion.PanelAnimator.prototype.start = function() { var self = this; this.startTime = (new Date).getTime(); this.timer = setTimeout(function() { self.stepAnimation(); }, this.interval); }; Spry.Widget.Accordion.PanelAnimator.prototype.stop = function() { if (this.timer) { clearTimeout(this.timer); // If we're killing the timer, restore the overflow // properties on the panels we were animating! for (i = 0; i < this.panelData.length; i++) { obj = this.panelData[i]; obj.content.style.overflow = obj.overflow; } } this.timer = null; }; Spry.Widget.Accordion.PanelAnimator.prototype.stepAnimation = function() { var curTime = (new Date).getTime(); var elapsedTime = curTime - this.startTime; var i, obj; if (elapsedTime >= this.duration) { for (i = 0; i < this.panelData.length; i++) { obj = this.panelData[i]; if (obj.panel != this.panel) { obj.content.style.display = "none"; obj.content.style.height = "0px"; } obj.content.style.overflow = obj.overflow; obj.content.style.height = (this.useFixedPanelHeights || obj.toHeight == 0) ? obj.toHeight + "px" : "auto"; } if (this.onComplete) this.onComplete(); return; } for (i = 0; i < this.panelData.length; i++) { obj = this.panelData[i]; var ht = this.transition(elapsedTime, obj.fromHeight, obj.distance, this.duration); obj.content.style.height = ((ht < 0) ? 0 : ht) + "px"; } var self = this; this.timer = setTimeout(function() { self.stepAnimation(); }, this.interval); }; Thank you very much to whomever can help. and by the way I have no knowledge in javascript. Alex I'm sorry I don't have a website to go with my question...it's on a dev server. But it's fairly simple I think. I have a php script running server side that I'm looping through (using different numbers at the end of the php page to get new content each iteration), and I want to grab the content of the php page to display, inside a google maps infowindow ideally. The problem is, right now the infowindow displays just the link. I want the content of what the link is (which is just a few words in any case). Here's the general code where I place the page inside a variable and then try to display the contents of the page in html variable (the link I show here won't work but it gives you the idea): Code: var hazard_links = "https://ch.noaa.gov/m/googleapi/rec/extracthazards.php?lat="+lat+"&lon="+lon; var html = '<span style="font-size: 10pt; color: red;"><hr><a href="'+hazard_links+'" target = "_blank">' + hazard_links + '</a>' + '<span style="font-size: 10pt; color: red;">'; Thanks for any help, Hello, I'm creating a section for a school website that will list over 9,000 book titles in four different categories (by Title, by Author, by Book Level, and by Points). The content is shown in a div and called and loaded via Ajax. Here is the test page: http://www.gilchrist.leon.k12.fl.us/ar/artest.htmlAfter you click "Go" when the drop down menu is displaying By Book Title, the content loads in the div in a few moments. Here is the content page that appears in the div after you click "Go": http://www.gilchrist.leon.k12.fl.us/...tByAuthor.html If possible, I need a "page loading..." script that will appear only after you click "Go" while the list of books is being loaded. I've been testing different ones I've found online, but can't get any to work. Of course, I'm not even sure if the script would be added to artest.html, 1112-QuistListByTitle.html, or a combination of both... Any help with this would be greatly appreciated. Thank you, Deborah Hi, Im new to javascript. I want to add a similar function on my blog like on http://techcrunch.com/2011/08/04/gro...tartup-obtiva/ when you press on author. It is a drop down made with javascript. Anybody can help with a similar javascript as I was trying different implementations for the whole night with no luck. Maybe, anybody know a similar javascript online which I could modify? Thanks in advance! If you want preload images on several pages of your site do you need to preload all images of your whole site on each page or only the images of the actual page?
|