JavaScript - Rolling Banner Events
Hi people,
I've been asked to build a rotative news/banner switcher. Like you would see on news channel on TV at the bottom. I am using setInterval() to call an xajax method every X seconds. Works great. I keep trace of an array index and return the next content everytime it is called. (Not forgeting to roll up the index (or go back to 0 if I reach the end)) So for so good. But I was asked to add mouse events to this. The ability to stop the rolling interval onmouseover and resume onmouseout. Same goes with a pause/play button. So I kill the interval using clearInterval(), its stops. onmouseout resumes the first timer AND Creates a new one so it doubles the rotations. I tried various solutions found on google but none of them works at all. I need help to properly start/stop pause/resume a javascript timer. now to the code. I'm using a little xajax here but my problem is from javascript. init() gets called on body onload() Code: function init(){ $xAjax_objResponse = initXajaxObject(); //time script to refresh the banner //I also declare the timer variable there. $xAjax_objResponse->script("var timerMarquise; xajax_refreshMarquise();"); //Starts the timer $xAjax_objResponse->script(getMarquisePlayScript()); return $xAjax_objResponse; } refreshMarquise() sets the banner content Code: function refreshMarquise(){ $xAjax_objResponse = initXajaxObject(); $oRedaction = unserialize($_SESSION["creation2"]["redact"]["obj"]); //Session object $oIdee = $oRedaction->getNextIdee(); //Gets the next object containing the info to show $innerMarquise = getMarquiseInner($oIdee); //builds the html to show the content $xAjax_objResponse->assign("redaction_marquise", "innerHTML", $innerMarquise); //Actually sets the result to the page //without anything to show, I don't display the banner $displayMarquise = count($oRedaction->getArrIdeesValides()) == 0 ? "none":"block"; $xAjax_objResponse->assign("redaction_marquise_cheat", "style.display", $displayMarquise); $_SESSION["creation2"]["redact"]["obj"] = serialize($oRedaction); //Save objects new state - modified index return $xAjax_objResponse; } getMarquisePlayScript() starts the timer Code: function getMarquisePlayScript(){ $script = getMarquisePauseScript(); //I clear the current timer $script .= "timerMarquise = window.setInterval(\"xajax_refreshMarquise()\", 3000);"; //This should call refreshMarquise every 3 seconds return $script; } getMarquisePauseScript() - should stop and clear the interval Code: function getMarquisePauseScript(){ return "window.clearInterval(timerMarquise);"; } Mouse events - call the pause and play scripts Code: onmouseover='xajax_pauseMarquise();' onmouseout='xajax_playMarquise(); thanks for help Similar TutorialsI am using a freebie script that changes css elements using onClick when you hit a button. I have 12 choices I want to add, and don't want 12 buttons, but rather a dropdown list. 2 button examples (and js code) is: <input onclick="changecss('li','background','url(images/list_02.jpg) no-repeat 10.2em .12em')" value="Change to BG 2" type="button" /> <input onclick="changecss('li','background','url(images/list_03.jpg) no-repeat 10.2em .12em')" value="Change to BG 3" type="button" /> How do I convert this to a SELECT list?? Thank you! -edit - nevermind. mods plz delete.
Hi buddys, I'm trying to create a rolling area on my webpage, which will rolling forever on the top corner of my webpage to show the up coming event, the following is my code, however it works in IE7 or lower, in IE 8, it only rolling one turn, in firefox, it's not moving at all!!! Can anyone help and see what shall I do with it?? Many thanks, Cat <DIV id=rolllink011 style="OVERFLOW: hidden; WIDTH: 189px; HEIGHT: 100px"> <CENTER> <DIV id=rolllink1011 style="WIDTH: 189px; HEIGHT: 120px"> <table width="100%" border="0" id="table011"> <tr> <td height ="100px" width="98%" id="TdBox011"> <p><strong>Events</strong></p> <p align="left">First Event ............Date</p> <p align="left">Second Event ........Date</p> <p align="left">Third Event ...........Date</p></td> </tr> </table> </DIV> </CENTER> <CENTER> <DIV id=rolllink2011></DIV></CENTER></DIV> <script language="Javascript"> function Marquee011(){ if(rolllink2011.offsetTop-rolllink011.scrollTop<=0) rolllink011.scrollTop-=rolllink1011.offsetHeight; else{ rolllink011.scrollTop++; } } function Start011(){ var rollspeed011=40; var rolllink1=TdBox011.offsetHeight; var temp=rolllink1; while(temp<rolllink011.offsetHeight) { document.getElementById("table011").insertRow(1); document.getElementById("table011").rows[1].insertCell(0).innerHTML=TdBox011.innerHTML; temp+=rolllink1; } rolllink2011.innerHTML=rolllink1011.innerHTML; var MyMar011=setInterval(Marquee011,rollspeed011); rolllink011.onmouseover=function() {clearInterval(MyMar011);} rolllink011.onmouseout=function() {MyMar011=setInterval(Marquee011,rollspeed011);} } setTimeout("Start011();",1000); </script> so i have to use the addEvent() to call the makeBannerAd function which i believe i have done so.... but then i gotta <div id = "bannerBox"> </div> and loop through all the iteams in my adsURL Array and for each item i must create the html fragment <div class = "bannerAd"> <a href = "url"> <img src = "bannerindex" /> </a> </div> i must set the z index number to each number ad to the value of the counter index and append the banner ad to the banner Box element.....Append the bannerBox to the documentbody, run the changeBannerAd() every 10 sec Banners.js Code: //this is the global scope here when you declare out side of a function it because global or at the top of the js file var nextAd; //this is going to be used to change or show the next banner ad to the web page function addEvent(object, evName, fnName, cap) { makeBannerAds(); if (object.attachEvent) { object.attachEvent("on" + evName, fnName); }//end if else if (object.addEventListener) { object.addEventListener(evName, fnName, cap); }//end else if }//end function addEvent function makeBannerAds() { //this creates a banner box to store the banner ads in var bannerBox = document.createElement("div"); bannerBox.id = "bannerBox"; for(var i = 0; i < document.adsURL.length; i++) { if(adsURL[i] != <div class = "bannerAd">, <a href ="url">, <img src ="bannerindex" />, </a>, </div>) { if (adsURL[i] = <div class = "bannerAd">, <a href ="url">, <img src ="bannerindex" />, </a>, </div>) else return adsURL[i] = <div class = "bannerAd">, <a href ="url">, <img src ="bannerindex" />, </a>, </div>; }//end if }//end if }//end function makeBannerAds ads.js Code: function storeURL() { //this creates a new array, the array is called adsUR: var adsURL = new Array(); //this stores each item in the array using a index place holder adsURL[0] = "testpage0.htm"; adsURL[1] = "testpage1.htm"; adsURL[2] = "testpage2.htm"; adsURL[3] = "testpage3.htm"; adsURL[4] = "testpage4.htm"; adsURL[5] = "testpage5.htm"; adsURL[6] = "testpage6.htm"; adsURL[7] = "testpage7.htm"; adsURL[8] = "testpage8.htm"; adsURL[9] = "testpage9.htm"; adsURL[10] = "testpage10.htm"; adsURL[11] = "testpage11.htm"; }//end function storeURL books.html file Code: <head> <!-- --> <title>Online Bookworms</title> <link href="bw.css" rel="stylesheet" type="text/css" /> <link href="bannerstyles.css" rel="stylesheet" type="text/css" /> <script src ="ads.js" type ="text/javascript"></script> <!--calls the external file called slideshow.js --> <script src ="banners.js" type ="text/javascript"></script> <!--calls the external file called slideshow.js --> </head> <body> <div id="page"> <h1 id="heading"><img src="bwlogo.jpg" alt="Online Bookworms" /></h1> <ul id="menu"> <li><a href="#">Home</a></li> <li><a href="#">Reviews</a></li> <li><a href="#">Forums</a></li> <li><a href="#">Book Swaps</a></li> <li><a href="#">OBW Store</a></li> <li><a href="#">Author's Corner</a></li> <li><a href="#">My Account</a></li> </ul> <ul id="menu2"> <li><a href="#">My Reading List</a></li> <li><a href="#">Review a Book</a></li> <li><a href="#">Join a Discussion</a></li> <li><a href="#">Post to a Forum</a></li> <li><a href="#">My Mail</a></li> <li><a href="#">My Posts</a></li> <li class="newgroup"><a href="#">Reading Recommendations</a></li> <li><a href="#">Books of the Month</a></li> <li class="newgroup"><a href="#">MP3 Downloads</a></li> <li><a href="#">Podcast</a></li> <li><a href="#">RSS Feeds</a></li> <li class="newgroup"><a href="#">Tech Support</a></li> <li><a href="#">Comments</a></li> <li><a href="#">About online BookWorms</a></li> </ul> <div id="main"> <h2>Welcome</h2> <p>Welcome to <strong>online BookWorms</strong> — your location on the Web for books, magazines, short stories, poetry, and essays. Please explore our online bookstore for the lowest prices on new and rare books. Share your love of reading by joining one of our many forums and discussion groups. Are you an aspiring critic? We welcome book reviews and essays on your favorite authors and works. </p> <h2>News</h2> <p>We are very happy to introduce the <a href="#">online BookWorms Podcast</a>. The podcast will contain free excerpts from great works of fiction and reviews of current books. You can quickly subscribe to this new BookWorms feature <a href="#">here</a>. </p> <p>Take a few moments now to explore our book shelves. And remember to patronize our sponsors by clicking the banner ads at the top of the page. Enjoy browsing our site! <p id="signature"> <img src="signature.jpg" alt="Helen Ungerstatz" /> </p> </div> </div> </body> </html> This is what I have: http://page-test.co.uk/js-test.html ..and it works exactly how I want it to, but I need it to work by doing these two things: (a) If you see in the change_button function, I have hard coded the 'name_can_vary' name element. I need to do it so this isn't hard coded (so it can work on any page/form). (b) I don't want to change any of the HTML, and I only want to change the code used in the change_button function (otherwise I will need to change many pages). Thanks in advance. i have a link that references: <a href="My_Video.asx">video</a>. when you click, video will open in the "windows media player" and the parent window goes blank. how can i prevent the parent window from going blank? thank you for help julio Hi guys, I'm a newbie so bear with me please. I downloaded this calendar which is now working great: JavaScript Calendar - Digital Christian Design (http://www.javascriptkit.com). Does anyone know how to change the date format from mm/dd/yyyy to dd/mm/yyyy? Also, is it possible to have links on such a calendar? I.e. in the event descriptions? Thanks. Hi Guys I have been trying to implement a way of using `onclick` to fill out a form field, with a Value assigned by a clickable rollover image. So i have a image rollover of a PC, i give the PC a Value? ID? of `PC No34` When the image is clicked it updates its Value of PC No34 to a Form text field which is named `pcid` the Form is on the same page as the PC rollover image. I have been trying most of the day but not getting it. Pls help Thanks for any help with this Willo With input box if you type something and refresh the page, the previous words that you typed in will be filtered and be display in a scroll down form in which you can click it. My question is, when I click the input type is it possible to scroll down, and display values that comes from a database? It should also filter the scroll down results. If it's possible I don't know how to do it. I tried googling but I can't find an explanation on how to do it. Thanks. <input type="text" value="" onclick=""> I was testing a required entry form, and i'm stuck. Code: <html> <head> <script type="text/javascript"> function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") { alert(alerttxt);return false; } else { return true; } } } function validate_form(thisform) { with (thisform) { if (validate_required(email,"Username must be filled out!")==false) {username.focus();return false;} } } </script> </head> <body> <form action="submit.htm" onsubmit="return validate_form(this)" method="post"> Username: <input type="text" name="username" size="20"> <input type="submit" value="Submit"> </form> </body> </html> i have this so far. i want to add a password part. i know i would take Code: Password: <input type="text" name="password" size="20"> and put it underneath the username part in the codes., but i don't know to do the rest, with the error message poping up. i have a checkbox: Code: <input type="checkbox" id="my_checkbox" name="option2" value="Check" checked>Check i want to add an event to it so that i do something to a dom element when it is checked and when it is not checked.What is the event and how can i get its status? I am having trouble understanding why this does not work? Code: <HTML> <HEAD> <TITLE>Event Loops</TITLE> <SCRIPT TYPE="text/javascript"> function seturl(a,b,c,d,e) { this[0] = a; this[1] = b; this[2] = c; this[3] = d; this[4] = e; } function selectPage(list) { var page = Math.floor(Math.random()*4); winow.open(list[page],"Random_Page"); } choices = seturl("http://www.google.com, "http://www.yahoo.com, "http://www.youtube.com, "http://www.bing.com, "http://www.xbox.com"); </SCRIPT> </HEAD> <BODY onLoad="selectPage(choices);"> <H1>Please Wait...</H1> </BODY> </HTML> Hi I have a requirement....I have a timer on a page. If the user leave the page (mouse goes off of that page) the timer starts and continues...and when the user comes into that page(mouse over that page) the timer goes off/STOP....Is this can be done?? using javascript??? pls help... I sometimes see that some people use this expression: event = event || window.event Why people need to do this? What does it mean? hello, Im trying to write a program when the user clicks on the button, the textbox should display "how are you ". This is what I tried : <html> <head> <title>"Click"</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p> <input name="text1" type="text" id="text1" value="textbox 1" onFocus="this.style.background ='yellow'" onBlur="this.style.background='white'"> </p> <p> <input name="text2" type="text" id="text2" value="textbox 2" onFocus="this.style.background = 'yellow'" onBlur="this.style.background='white'"> </p> <p> <button onclick="textbox1.value="how are you">Click Me!</button> </p> </body> </html> i have placed a text box with onclick and onblur event. onclick shows contents(links) of a div tag below it and onblur hides the div basically it was a jquery based drop down menu but due to some problem I need to avoid jquery. Now the problem happens when a link of div tag is clicked. The link does not work due to onblur event on the textbox. Any suggestion? Quote: <input type="text" style="text-transform: capitalize;" value="" class="abd_txtfld" name="loc" id="loc" onclick="gettabcontentSearch('','')" onblur="hide()"/> <div id="cityddsearch" class="select_citydd" style="position: absolute; margin-top: 2px; left: 5px; display: none;"> <ul> <li><a href='../link1.asp'>link1</a></li> <li><a href='../link2.asp'>link2</a></li> <li><a href='../link3.asp'>link3</a></li> </ul> </div> I'm having some problem with this DHTML app. The problem is that when i click on an image button, nothing happens. I have verified that the DOM event handlers are loaded. However, when i click on the images (buttons), nothing happens Code: var PenSize = "3"; var PenColor = "Black"; var LoadFile = ""; var UIstatus = "visible"; var CurrentNote = 0; var BGcolor = "#C7C1A3"; var DataPath = "\Data\\"; var ImageExtension = ".img"; var FileList = []; var SystemPath; var UIstatusLandscape = "visible"; var UIstatusPortrate = "hidden"; var Server = "localhost"; var UserName = "guest"; var Password = "guest"; var NxtNote = new Image(); var Mode = "Landscape"; var DataLibrary = "notes.txt"; document.onkeyup = ToggleUI; // Startup Script if (document.addEventListener) { document.addEventListener("DOMContentLoaded", LoadEventListeners, false); alert("loaded"); } function LoadEventListeners() { // Event Listeners for UI Buttons var eventUp = document.getElementById("UpNote"); var eventPlus = document.getElementById("AddNote"); var eventSave = document.getElementById("SaveNote"); var eventClear = document.getElementById("ClearNote"); var eventDelete = document.getElementById("DeleteNote"); var eventOptions = document.getElementById("Options"); var eventDown = document.getElementById("DownNote"); eventUp.addEventListener("click", NoteUp, false); eventPlus.addEventListener("click", AddNote, false); eventSave.addEventListener("click", SaveNote, false); eventClear.addEventListener("click", ClearSketch, false); eventDelete.addEventListener("click", DeleteNote, false); eventOptions.addEventListener("click", ConfigOptions, false); eventDown.addEventListener("click", NoteDown, false); // Event Listeners for the Options Dialogue var eventDown = document.getElementById("OptionsClose"); eventDown.addEventListener("click", ConfigOptions, false); // Finish the Startup Process Init(); } function Init() { // Get the System Path GetSystemPath("SketchBook.html"); // Load All Filenames of the DataPath directory into an array var TmpLoad = LoadFromDisk(SystemPath + DataPath + DataLibrary); // Check to see if the Notebook is blank if(TmpLoad == null) { // The botebook is Blank alert("Notebook is Blank"); return; } // Parse the CSV file data into an Array FileList = TmpLoad.split(","); //Load the first Note onto the canvas // if there are no notes in the directory, don't try to load anything if(FileList.length < 0) { var Source = LoadFromDisk(FileList[CurrentNote]); NxtNote.src = Source; // Load the NoteBookCounter data into the innerHTML of it's DIV // document.getElementById("NoteBookCounter").innerHTML = "<center><font size='2'>" + CurrentNote + " / " + FileList.length + "</font></center>"; // Load the image data onto the canvas var canvas = document.getElementById('SketchPage').getContext('2d'); canvas.drawImage(NxtNote , 0, 0); return; } } function ConfigOptions() { if (document.getElementById("Options").style.visibility == "hidden") { document.getElementById("Options").style.visibility = "visible"; } else { document.getElementById("Options").style.visibility = "hidden"; } // Modify the variables of any selections that were made PenSize = document.getElementById('GetPenSize').value; PenColor = document.getElementById('GetPenColor').value; } function ToggleUI(e) { var KeyID = (window.event) ? event.keyCode : e.keyCode; // KeyValue 18 is the ALT key var KeyValue = 18; // Use a key to hide the toolbars so that most of the screen is used for the UI // ********** If the device is in Landscape Mode, toggle the Portrate-Style UI Toolbar if(Mode == "Landscape") { if(KeyID == KeyValue) { if(UIstatusLandscape == "visible") { UIstatusLandscape = "hidden"; document.getElementById("UI_Landscape").style.visibility = "hidden"; return; } if(UIstatusLandscape == "hidden") { UIstatusLandscape = "visible"; document.getElementById("UI_Landscape").style.visibility = "visible"; } } } // ********** If the device is in Portrate Mode, toggle the Portrate-Style UI Toolbar if(Mode == "Portrate") { if(KeyID == KeyValue) { if(UIstatusPortrate == "visible") { UIstatusPortrate = "hidden"; document.getElementById("UI_Portrate").style.visibility = "hidden"; return; } if(UIstatusPortrate == "hidden") { UIstatusPortrate = "visible"; document.getElementById("UI_Portrate").style.visibility = "visible"; } } } } function Draw(element, event) { document.addEventListener("mousemove", PenHandler, true); document.addEventListener("mouseup", upHandler, true); event.stopPropagation(); event.preventDefault(); function PenHandler(event) { var x = event.clientX; var y = event.clientY; // mouse event goes here var canvas = document.getElementById("SketchPage"); var ctx = canvas.getContext("2d"); if (PenShape ="Circle") { // This draws a circle ctx.fillStyle = PenColor; ctx.beginPath(); ctx.arc(x, y, PenSize, 0, Math.PI*2, true); ctx.closePath(); ctx.fill(); } event.stopPropagation(); } function upHandler(event) { document.removeEventListener("mouseup", upHandler, true); document.removeEventListener("mousemove", PenHandler, true); event.stopPropagation(); } } function SaveNote() { alert("triggered"); return; // Get the current file name var FileName = SystemPath + DataPath + CurrentNote + ImageExtension; // Convert the Canvas Data into a Base64 encoded PNG image var Note = document.getElementById("SketchPage").toDataURL(); // Write the PNG file to the disk SaveToDisk(FileName, Note); // Update the Note Library file // Read in the current DataLibrary File's Data var Tmp = LoadFromDisk(SystemPath + DataPath + DataLibrary); var NewData = Tmp + CurrentNote + ImageExtension + ","; // Finally Save the updated DataLibrary file SaveToDisk(Tmp, NewData); alert("saved"); } function NoteUp() { // Display the previoius note CurrentNote--; // Make sure you don't incrimnet to a non-existant note if(CurrentNote == -1) { CurrentNote = FileList.length; } var Source = LoadFromDisk(FileList[CurrentNote]); NxtNote.src = Source; // Load the image data onto the canvas // Clear the Pre-existing Canvas Data First ClearSketch(); var canvas = document.getElementById('SketchPage').getContext('2d'); canvas.drawImage(NxtNote, 0, 0); } function NoteDown() { //Display the Next note CurrentNote++; // Make sure you don't incrimnet to a non-existant note if(CurrentNote > FileList.length) { CurrentNote = 0; } var Source = LoadFromDisk(FileList[CurrentNote]); NxtNote.src = Source; // Load the image data onto the canvas // Clear the Pre-existing Canvas Data First ClearSketch(); var canvas = document.getElementById('SketchPage').getContext('2d'); canvas.drawImage(NxtNote, 0, 0); // Update the NoteBookCounter data into the innerHTML of it's DIV //document.getElementById("NoteBookCounter").innerHTML = "<center><font size='2'>" + CurrentNote + " / " + FileList.length + "</font></center>"; return; } function DeleteNote() { // Delete The current note alert("Deleting Page - " + FileList[CurrentNote]); // Remove the file from the File System DeleteFile(FileList[CurrentNote]); // Remove the Element containing the FileName to be deleted from the array for (var x = 0; x < FileList.length; x++) { if(FileList[x] == CurrentNote + ImageExtension) { FileList.splice[x]; return; } } // Rewrite the Library File var TmpData = ""; for (var x = 0; x < FileList.length; x++) { TmpData = TmpData + FileList[x] + ","; } // Write the new Library File SaveToDisk(SystemPath + DataPath + DataLibrary, TmpData); // Load The Previous Note // Display the previoius note CurrentNote--; // Make sure you don't incrimnet to a non-existant note if(CurrentNote == -1) { CurrentNote = FileList.length; } // If the DataLibrary is zero length - just clear the Canvas and Return var TmpLoad = LoadFromDisk(SystemPath + DataPath + DataLibrary); if(TmpLoad == null) { CurrentNote = 0; ClearSketch(); return; } // Your about to place a new image on the Canvas // Clear the Current Canvas Data First ClearSketch(); var Source = LoadFromDisk(FileList[CurrentNote]); NxtNote.src = Source; // Load the image data onto the canvas var canvas = document.getElementById("SketchPage"); var context = canvas.getContext("2d"); canvas.drawImage(NxtNote, 0, 0); } function AddNote() { // Add a note to the notebook and at the end of the File List // **** Later this function should be modified to be an INSERT function rather than just an add // Just incase the user needs to go back an edit and add more things to their notebook var NumberOfNotes = FileList.length; CurrentNote = NumberOfNotes + 1; // Clear the Canvas ClearSketch(); // Write a blank image file to the Data directory so that we have the actual file there var FileName = SystemPath + DataPath + CurrentNote + ImageExtension; // Write it to the disk SaveToDisk(FileName, "Null Content"); // Add the new Note Data to the end of the array FileList.length++; FileList[FileList.length] = CurrentNote + ImageExtension; // Rewrite the Data Library File TmpData = ""; for (var x = 0; x < FileList.length; x++) { TmpData = TmpData + FileList[x] + ","; } // Write the new Data Library to the Disk SaveToDisk(SystemPath + DataPath + DataLibrary, TmpData); // Refresh the Directory List FileList = []; // Load All Filenames of the DataPath directory into an array var TmpLoad = LoadFromDisk(SystemPath + DataPath + DataLibrary); // Parse the CSV file data into an Array FileList = TmpLoad.split(","); } function ClearSketch() { // Clear the contents of the Canvas //Draw a rectangle that covers the canvas var canvas = document.getElementById("SketchPage"); var ctx = canvas.getContext("2d"); ctx.fillStyle = BGcolor; ctx.fillRect (0, 0, canvas.width, canvas.height); } function Crypt(method) { // This function will Encrypt or Decrypt All the NoteData if(method == "encrypt") { return; } if(method == "decrypt") { return; } } function Archive(method) { // This function will Restore or Backup all NoteData to a network resource if(method == "restore") { return; } if(method == "backup") { for(var x = 0; x > FileList.legth; x++) { // Read the data of each note var NoteData = LoadFromDisk(FileList[x]); // Upload the Note to the Server var Url = Server + "/Backup.php?" + x + "?" + NoteData; ajaxRequest(Url); } return; } } // These are the Ajax Functions for Sending and Recieving Files function callback(serverData, serverStatus) { alert(serverData); // Called automatically when we get data back from server } // Display an alert box with the recieved data var url='http://somedomain.com/getdata.php?doc=sometext.txt'; // This is the URL we will call. function ajaxRequest(url) { var AJAX = null; // Initialize the AJAX variable. if (window.XMLHttpRequest) { // Does this browser have an XMLHttpRequest object? AJAX = new XMLHttpRequest(); // Yes -- initialize it. } AJAX.onreadystatechange = function() { // When the browser has the request info.. if (AJAX.readyState == 4 || AJAX.readyState == "complete") { // see if the complete flag is set. callback(AJAX.responseText, AJAX.status); // Pass the response to our processing function } // End Ajax readystate check. } AJAX.open("GET", url, true, UserName, Password); // Open the url this object was set-up with. AJAX.send(null); // Send the request. } // ******************** These are the XPCOM Functions ************************ function GetSystemPath(ApplicationName) { // This function should Detect the system directory of the app // and return that string as the SystemPath variable // You must supply the filename of the HTML file that it is being called from // I suppose later i could add the code to detect the HTML's actual file name // It's on the ToDo List... var GetSysPath = self.location; GetSysPath = GetSysPath + ""; Get = GetSysPath.replace("file:///" , ""); Get = Get.replace(/\//g , "\\"); Get = Get.replace(ApplicationName, ""); SystemPath = Get; return SystemPath; } function DeleteFile(FileName) { // Delete a local file netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance(); if (aFile instanceof Components.interfaces.nsILocalFile) { aFile.initWithPath(FileName); aFile.remove(false); } } function SaveToDisk(filepath, content) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("Permission to save file was denied."); } var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath( filepath ); if ( file.exists() == false ) { file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 ); } var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance( Components.interfaces.nsIFileOutputStream ); outputStream.init( file, 0x04 | 0x08 | 0x20, 420, 0 ); var output = content; var result = outputStream.write( output, output.length ); outputStream.close(); } function LoadFromDisk(filePath) { if(window.Components) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if (!file.exists()) return(null); var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); inputStream.init(file, 0x01, 00004, null); var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); sInputStream.init(inputStream); return(sInputStream.read(sInputStream.available())); } catch(e) { //alert("Exception while attempting to load\n\n" + e); return(false); } return(null); } This is my problem: I have a seperate page on my website with a list of upcoming events. On that page I have the date of the upcoming event and then the description. On the main page of my website, I have a small table with the next four upcoming events(with the dates of course). So far I have been manually changing the four closest upcoming events on the main page. (just copy and paste from the upcoming events page) My question: Can javascript "grab" from the upcoming events page the next four events, and have them automatically pasted into the table on my main page? And if it is possible, what code(s) do I need? This way I don't have to do it manually and will save me lots of time. P.S. I have a weak understanding of javascript, but throw any code at me and I will try to understand it. Thank you Hi, I am trying to get this code to work in IE. It works on Firefox, but not on IE. Basically it blocks out scrolling the page down with space button, and registers up and down keys to run some code. The entire case statement including event registering and my code works completely fine in FF but it just won't work in IE (meaning that I can scroll down with space, and up and down with the up and down keys respectively). Here's the code, any help would be much appreciated. By the way I put this function in the HEAD section. Code: window.onkeydown = function(event) { // No space scrolling! switch (event.keyCode) { case 32: return false; break; case 38: { if (rB_Script.last_item <= 1000) { return; } else { rB_Script.focus_on_step(rB_Script.last_item - 1); } return false; break; } case 40: { if (rB_Script.last_item >= rB_Script.final_item) { return; } else if (rB_Script.last_item != -1) { rB_Script.focus_on_step(rB_Script.last_item + 1); } else { rB_Script.focus_on_step(1000); } return false; break; } } } Thank you very much! Hi, I am having a slight difficulty and hope someone can easily set me straight. I am trying to use the following code to track a button click and the second onclick event, the urchin tracking is not being completed but the first function is.... can someone please hopefully set me straight easily on the code? Many thanks Steve123. Code: <input type="submit" name="Submit" value="Buy Product" class="buy" onClick="document.form.submit();javascript:urchinTracker('/html/productdeals_button.asp')"> |