JavaScript - Advanced Scripting: Need Help To Make Ie8 Behave!
Ok, for starters I'm not a beginner and my website is running under standards mode (not quirks).
When my site loads I perform: Code: window.location.replace(window.location.href + "#encodedstuff"); The effect being that no new history points are created and the very first history point now includes some encoded info in the hash. When the user closes and relaunches IE8 and then chooses "reopen last browsing session" I expect IE to make the request for the page including the hash value. It does NOT! It simply makes the request for the URL without the hash (and then adds the hash as the next history point). I need help figuring out why and if there is a way to accomplish this without needing to add a parameter to the location get request (which will cause my site to reload upon launch if this parameter is not already set... I don't want it doing that). Please note that the browser DOES behave if I copy the new URL, including the hash value and paste it into a new tab (closing the old tab). When I relaunch IE8 and reopen the previous session it does make the request with hash value and my site is able to get the required info out of the hash. It only fails for a tab that initially did not have a hash and my script performs the above location.replace. Solving this is critical for my application, so I seriously appreciate any help! Similar TutorialsHi all Is using the real form submit button a problem in any way? Can it actaully send a form when a person uses 'enter' in a text field. When I use this submit, it triggers my validation which is great. Code: <input type="submit" value="OnSubmit validate" /> However this way doesn't seem to trigger my validation although It may solve the above form send problem (if that realy exists). How do I get it to act the same as real submit so it will trigger validation like onsubmit above? Code: <input type="button" value="Send Feedback" onclick="this.form.submit()" /> LT does any of that make sense? all ideas helpful and appreciated Code: <html> <head> <title>lightning generator</title> </head> <body> <canvas id='world' width='500' height='500' style='border: 1px solid black; padding:0;'></canvas> <script type="text/javascript"> var world = { } ; world.ground = { } ; world.ground.slice = []; var ctx = document.getElementById( 'world' ).getContext( '2d' ); world.ground.make = function( GArray ){ ctx.fillStyle = '#000'; for ( var i = 0; i <= GArray.length; i ++ ){ if ( GArray[i + 1] === null ){ GArray[i + 1] = GArray[i]; } world.ground.slice[i] = GArray[i]; ctx.moveTo( i, - 500 ); ctx.lineTo( i, GArray[i] ); } }; world.ground.make( [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29] ); </script> </body> </html> it should make a simple area at the bottom of the canvas thats black., a incling with a slope of 2 and than a straight line. .....dots ar unfiled..... ..._____________ ../ ./filled area... / Hi all I have created a website http://www.clickmunki.com with a jQuery vertical panel that collapses and expands in the top left of each page. In my offline code (which I have not yet uploaded to the live site) I have set the panels to display by default so the user automatically has the information available to them on each page as they scroll through the site. My problem is that the panels are not behaving independently of each other. When one panel is collapsed then they all collapse instead of just the one that the user has clicked. This is my first attempt at using javascript and jQuery and I am not sure how to resolve this. Any assistance would be very much appreciated. This is my js: Code: $(document).ready(function(){ $(".trigger").click(function(){ $(".panel").toggle("fast"); <! panel is for the panel on the home page --> $(this).toggleClass("active"); return false; }); $(document).ready(function(){ $(".trigger").click(function(){ $(".panel2").toggle("fast"); <! panel2 is for the panels in the body of the site --> $(this).toggleClass("active"); return false; }); Kind regards Anne So I wrote a script to slide various divs horizontally. It takes 2 seconds to start and then begins, sliding, then stops, then slides, until all four slides are shown, and the slides back to the first one. My issue is I have two buttons that should take over and kill the auto sliding. Also the script is giving me errors. That mastertimer, and loopertimer is not defined... Why is that? Here is the code Code: <script type="text/javascript">// <![CDATA[ function restartSlide(item){ item.style.left = parseInt(item.style.left) + 60 +'px'; var resetLooperSl = setTimeout(function(){restartSlide(item)},15); if(parseInt(item.style.left) >= 0){clearTimeout(resetLooperSl);return;} } function stopSlide(){ clearTimeout(loopTimer); } function animateSlide(element,limit,transition){ if(transition == "stop" && parseInt(element.style.left) > -2460){ limit = limit - 820; } else if(transition == "stop" && parseInt(element.style.left) <= -2460){ limit = limit + 820; stopSlide(); } element.style.left = parseInt(element.style.left) -20 + 'px'; if(parseInt(element.style.left)<= limit){ setTimeout(function(){animateSlide(element,limit,"stop")},4000); clearTimeout(MasterTimer); } var loopTimer = setTimeout(function(){animateSlide(element,limit,"flow")},15); } function autoSlide(){ var MasterTimer; var RestarterTime; var adContainer = document.getElementById('adwrap'); adContainer.style.left = '0px'; MasterTimer = setTimeout(function(){animateSlide(adContainer,0,"stop")},3000); RestarterTimer = setTimeout(function(){restartSlide(adContainer)},25000); } addEvent(window, 'load', autoSlide); function btnSlideNow(elem, incremental){ elem.style.left = parseInt(elem.style.left) + incremental + 'px'; setTimeout(function(){btnSlideNow(elem, incremental)},30) } function btnActions(elem){ var incremental; if(elem.id == 'btnAdLeft'){incremental = 30} else if(elem.id == 'btnAdRight'){incremental = -30} btnSlideNow(elem, incremental); } function adButtons(){ document.getElementById('btnAdLeft').onclick = function(){btnActions(this)} document.getElementById('btnAdRight').onclick = function(){btnActions(this)} } addEvent(window, 'load', adButtons); // ]]></script> Also I'd like to see how you experienced scripters would write this cleaner. I'd like to see that, as I am new to js. It would help me learn. thanks Hello, If i use this to protect myself from XSS scripting, do you think that it will be enough? http://www.hscripts.com/scripts/Java...e-html-tag.php Thank you. Can someone not just block this script, by banning javascript.? Quote: Hi, below code is only working in Firefox but not in Internet Explorer. Once I select YES from drop down list, then the next text box should be greyed out and the second should show value 10. This works in Firefox but not in Firefox . Code: <html> <head> <title>Untitled</title> <script> function enable() { document.myForm.textbox.disabled = false; document.myForm.textbox2.value = 0; } function disable() { document.myForm.textbox.disabled = true; document.myForm.textbox2.value = 10; } function value() { document.myForm.textbox2.value = 10; } </script> </head> <body> <form name="myForm"> <table> <tr> <label> Do you accept </label> <td> <select name="na"> <option value="yes" onclick="disable()"> YES </option> <option value="no" onclick="enable()"> NO </option> <option value="NA" onclick="disable()"> NA </option> </select> <input type="text" name="textbox" value="" disabled> <input type="text" name="textbox2" value="10" > </td> </tr> <tr> <td> </td> </tr> </form> </body> </html> Dear Forum, I have a website of quite a few pages which also has a style sheet switcher so the user can select their own customised graphics and layout (css file) these css files load in the graphics but only when the call is clicked... even if the page has already been opened for seconds or minutes when the graphics could have been loaded in for an instant switch. so i implemented the following code: Code: <SCRIPT language="javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </SCRIPT> <body onLoad="MM_preloadImages('/corporate/heading.png','/creative/heading.png','/earth/heading.png','/under-the-sea/heading.png','/space-and-stars/heading.png','/classical/heading.png','/corporate/document.jpg','/space-and-stars/document.png','/creative/document.jpg','/earth/background.jpg','/under-the-sea/background.jpg','/classical/document.png','/classical/background.jpg','/under-the-sea/document.png','/corporate/home-graphics.png','/earth/content.jpg','/earth/footer.jpg','/earth/home-graphics.png','/under-the-sea/home-graphics.png','/creative/home-graphics.png','/space-and-stars/background.jpg','');"> it works fantastically - you open the page and as long as it takes to notice where you can click the styles is the same amount of time it takes to have the styles cached for the styles switch immediately and effortlessly. however, the site has grown and is now quite a number of pages with the above in each html file. ive just added a "creative 2" style, which has caused the above to need updating........ the maintenance of this code is inefficient to edit each page. would someone be able to point or show me how to, in principle: Code: <body onLoad="MM_preloadImages('/styles-code.js);"> styles-code.js?? page: '/corporate/heading.png', '/creative/heading.png', '/earth/heading.png', '/sea/heading.png', '/classical/heading.png', '/corporate/background.jpg', '/creative/background.jpg', '/earth/background.jpg', '/sea/background.jpg', '/classical/background.jpg', etc and have 1 page of this code called in by all pages in an easy to see and edit list? would really appreciate guidance with this, Hi guys, I'm trying to work on this code to make transportation an additional option when adding a reservation at http://morningstararuba.com/reservat...servation2.htm. But there must be some errors, I included part of the code, because it does not activate the selection box. Appreciate your help, thanks! Code: <tr> <td>Champagne:</td> <td><select name="champagne" size="1" disabled tabindex="16" onchange="javascript:total_cost(passangers,charter_request,champagne,cost)"> <option selected value="None">None</option> <option value="Freixenet">Freixenet</option> <option value="Veuve Cliquot">Veuve Cliquot</option> <option value="Veuve Cliquot Vintage">Veuve Cliquot Vintage</option> <option value="Moet Chandon Brut">Moet Chandon Brut</option> <option value="Moet Chandon Brut Rose'">Moet Chandon Brut Rose'</option> <option value="Moet Chandon Rose' Vintage">Moet Chandon Rose' Vintage</option> <option value="Dom Perignon">Dom Perignon</option> <option value="Dom Perignon Rose'">Dom Perignon Rose'</option> </select></td> </tr> <tr> <td>Transportation:</td> <td><select name="transportation" size="1" disabled tabindex="16" onchange="javascript:total_cost(passangers,charter_request,champagne,transportation,cost)"> <option selected value="None">None</option> <option value="Bentley Roundway">Bentley Roundway</option> </select></td> I want to have a real time text ticker. I would be able to type something in and it would continue to scroll until I typed something else (followed by the return key), and it would scroll that, without the end-user having to refresh their screen to see the update. I was hoping their might be a script out there already that does that, but since I can't find one, I thought I'd see about trying to create one. What would be the most practical scripting language to use? Or if you know of something that does this already, could you point me in the right direction. Hi there everyone.. I have a little assignment due and I have been absent for a long time (wont go into details) but I'm sorta lost on how to do it. I'm sure it's really easy. Code: Scanner kbd = new Scanner(System.in); System.out.println("\n\n" + "Box Drawing Program\n\n" + "When prompted, " + "enter the height & width of a box. " + "Enter a negative height\nto finish.\n\n"); System.out.print("Enter a height & width: "); int height = kbd.nextInt(); while (height > 0) { int width = kbd.nextInt(); kbd.nextLine(); drawBox(height, width); System.out.print("Enter another height & width: "); height = kbd.nextInt(); } kbd.nextLine(); System.out.println(); "Now add a helper function named drawBox. It takes the height and width from main and prints a box of that size." "Here is a sample run: Box Drawing Program When prompted, enter the height & width of a box. Enter a negative height to finish. Enter a height & width: 4 7 ******* * * * * ******* Enter another height & width: 3 8 ******** * * ******** Enter another height & width: -1 " I know it's probably something easy, but I'm really lost.. Any help would be greatly appreciated. Edit: The box seems to mess up when I paste it, it should look like a rectangle, haha Can Someone please help me with the script for making this work. This is a assignment I am having trouble with the required codes bring up a discount box displaying the output details dependent on the discount code used. I Belleive the While operator is used for this can someone please help me?I no my codes are probably all wrong but am desperate for help thanks For this part of the question you can assume that the user always inputs one of the three correct codes, FSSAVE, ISSAVE and SOSAVE. If (Discount code entered is FSSAVE) give discount one else if (discount code entered is ISSAVE) give discount 2 else if (discount code entered is SOSAVE) give discount 3 var discount; fSSAVE; iSSAVE; sOSAVE fSSAVE = 20p iSSAVE = 30p sOSAVE = 40p discount = window.prompt('Please enter a discount code,' Here'); Issue 1 - Solved I have this workbook with multiple sheet. I need that the data from the mail sheet gets sorted to the other sheets based on the value in certain cells. https://docs.google.com/a/housing.co...it?usp=sharing IQT 3.0 is the main sheet The condition to copy the data is simple based on data if available in column I to N then the data in that full row should get copied to the sheets with the same name as these columns. multiple entries is possible if you look at the test data Row 2 has data available in 3 columns i,K&L now all the relavent data should get copied to the sheets with the same name as these columns & the data should go under the appropriate columns in these sheets. Issue 2 - Pending Need Help Each error sheet is worked upon by different teams is there a way to ensure that the status of the project in the main sheet cannot be made live till all errors for that particular project have the YES selected under Resolved & Passed by QC. If the Resolved & Passed by QC. are YES for each error in a particular project only then can the status in the main sheet be changed to LIVE & highlighted in green else it should show the status as PENDING only no colour. Once the Status is live then the project should be moved to the archive sheet & also removed from the error sheets so that the only projects visible are the ones pending to be resolved & sorted by process date. also need to ensure that no one except the sheet owner can delete the code or the sheet. Hello, I am trying to create an imageuploader for my forum hosted on domain forum.com (fictional domain name) The image uploader is hosted on domain uploader.com (fictional domain name) When the uploader is done i want info to be passed from the uploader to the texteditor on the forum using javascript. I tried everything i could think of with document.getElementById but to no avail. The element on the forum is clickableEditor.textarea Is it possible and if so, can someone please help me out? I am trying to re-write a script that I found on w3schools. The script should check whether ALT key was pressed or not. My objective is not to use any inline scripts and to refer to the event within a function. My script is not working. Could someone please have a look at it and help me? Thank you very much <code> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Event Object</title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <script type="text/javascript"> function general() { document.getElementsByTagName("body")[0].onmousedown=function() { if(document.getElementsByTagName("body")[0].onmousedown.altKey==1) { alert("You pressed Alt key"); } else { alert("ALT key was not pressed"); } } } window.onload=general; </script> </head> <body> <p> Click somewhere in the document, we will tell you whether or not you pressed ALT key </p> </body> </html> </code> I am not super familiar with code - I can easily take code and with a little direction get the desired end result so anyone who can help me with this it will be VERY appreciated. I don't even know what terms to search in order to create a page that I am looking for.... So here goes: I want to model our distributor page after a R E D K E N.com Distributor Locator Page. Here is what happens.... There is a drop down menu of the 50 states, and when you select the state the table of information below changes. screen shots below I am sure this is fairly easy to resolve, however I don't know where to begin. Thank You in advance for your time. Kristi Hi, this will sound stupid, because it is, but i was browsing reddits creepy subreddit, and there was a post (This website's description on Google... : creepy) that was about a creepy site with some ambiguous text, i pressed the link in the comments and got to the site, when i went back, i kept seeing a smudge but only on the reddit creepy subreddit on the screen, idk how this is possible, i've never seen it before, and its on all devices that are connected to the same router, they all get that smudge, so do you guys know any possible ways to fix this? the site is (Krakl) and deleting cookies, cache, restarting etc didnt help, and that smudge is really annoying. tldr; visited site, got smudge trough a script on other site, i see it on other pcs connected to the same internet too. How to remove this, could my pc be infected or something, is this XSS? Sorry, i know that no one here is probably used to this, but i just about exhausted every single option with no results and i want to know whats causing this. Reply With Quote // So, I don't know if javascript is not able to calculate this but I would like to know if it's possible here is the formula: Monthly Payment = premium x [(0.006(1.006)^term)/((1.006)^term-1)]; Here is the same function with values. 2131.33 = 6383.40 x [(0.006(1.006)^3)/((1.006)^3-1)]; I haven't been able to make it come out correctly yet. Is it even possible? Hi there, Hopefully someone will be able to help me here. I found the below script that works fine for the actual countdown, but when the user refreshes the page, the countdown starts from 5 minutes again. What I am trying to do, is handle users that put something in their shopping cart and then get side tracked or what ever reason and that same product then being purchased by another person when I only have 1 left. So using PHP I am going to subtract the qty of that product by 1 and then I want the website to either put it back, if the users checkout times out, or if a normal process it is taken out permanently. So long story short I think I need some sort of 'memory' for the javascript, so the user can't just keep refreshing and it starting from 5 minutes each time. Also it needs to be carried through to other pages. Your help is greatly appreciated. Thanks, Simon. Code: <script type="text/javascript"> /* This script and many more are available free online at The JavaScript Source :: http://javascript.internet.com Created by: Neill Broderick :: http://www.bespoke-software-solutions.co.uk/downloads/downjs.php */ var mins var secs; function countdown() { mins = 1 * CDm("5"); // change minutes here secs = 0 + CDs(":01"); // change seconds here (always add an additional second to your total) CDredo(); } function CDm(obj) { for(var i = 0; i < obj.length; i++) { if(obj.substring(i, i + 1) == ":") break; } return(obj.substring(0, i)); } function CDs(obj) { for(var i = 0; i < obj.length; i++) { if(obj.substring(i, i + 1) == ":") break; } return(obj.substring(i + 1, obj.length)); } function CDdis(mins,secs) { var disp; if(mins <= 9) { disp = " 0"; } else { disp = " "; } disp += mins + ":"; if(secs <= 9) { disp += "0" + secs; } else { disp += secs; } return(disp); } function CDredo() { secs--; if(secs == -1) { secs = 59; mins--; } document.getElementById("countdown").firstChild.nodeValue = CDdis(mins,secs); //document.cd.disp.value = dis(mins,secs); // setup additional displays here. if((mins == 0) && (secs == 0)) { window.alert("Time is up. Press OK to continue."); // change timeout message as required // window.location = "yourpage.htm" // redirects to specified page once timer ends and ok button is pressed } else { countdown = setTimeout("CDredo()",1000); } } function coundowninit() { countdown(); } </script> Code: <span id="countdown"> </span> I have used a Javascript to prepopulate text fields and checkbox's etc. However I can't make it populate a text area. Would anyone be kind enough to help me with the code for it? Any help would really be appreciated: (source code below) Code: // preset.js Copyright 2009 by Richard L. Trethewey - All Rights Reserved // Permission is granted to use this code as long as this copyright notice // is left intact. For more information, see http://www.rainbodesign.com/pub/ // First, get the query string contents from the URL used by lopping off the "?" var query = location.search.substr(1, location.search.length-1); function findForm(theForm) { var formCount = document.forms.length; if (document.getElementById) { formElement = document.getElementById(theForm); } else { for (i=0; i<formCount; i++) { if (document.forms[i].name == theForm) { formElement = document.forms[i]; } } // endFor } // endif document.getElementById return formElement; } // end findForm function setOption(theOption,choice) { max = theOption.length; for (i = 0; i < max; i++) { if (theOption.options[i].value == choice) { theOption.options.selectedIndex = i; } } // end for i } // end setOption function setRadio(theOption,optionName) { max = theOption.length; for (i = 0; i < max; i++) { // alert(theOption[i].name + ' ' + theOption[i].checked); if (theOption[i].value == optionName) { theOption[i].checked = true; } } // end for i } // end setRadio function fixQString(theStr) { pattern = '\\+'; flags = 'g'; reg_exp = new RegExp(pattern, flags); theStr = theStr.replace(reg_exp, ' '); theStr = unescape(theStr); return theStr } // end fixQStr function populate(formName) { if (query) { // Was there a query string? var params = query.split("&"); // Yes! Split them up var theForm = findForm(formName); // Locate the form with the correct name/ID if (theForm != null) { // Did we find the form? for (q=0; q<params.length; q++) { xy = params[q].split("="); // Split the command into name/value pair paramName = xy[0]; newValue = fixQString(xy[1]); if (theForm.elements[paramName]) { // does named element exist? // alert(theForm.elements[paramName].type + ' ' + paramName); switch(theForm.elements[paramName].type) { case 'text': theForm.elements[paramName].value = newValue; break; case 'hidden': theForm.elements[paramName].value = newValue; break; case 'select-one': setOption(theForm.elements[paramName], newValue); break; case undefined: // a kludge to handle radio buttons setRadio(theForm.elements[paramName], newValue); break; case 'checkbox': theForm.elements[paramName].checked = true; break; } // end switch } // endif theForm.elements[paramName] } // end for q } // endif {theForm) } // endif (query) } // end populate() |