JavaScript - Is It Possible To Stop Document.writeln() Opening A New Page Errors?
Probably a stupid noob question, is there any way I can stop document.write from outputting info to a new page I would prefer to have it shown in a textarea.
Info from an array that is suppose to display in a text area when button is clicked and when another button is clicked it is suppose to show some other info. But what happens is the first info displays in textarea for a few seconds and then the second info is displayed but on a new page and not the textarea where I want it to go I have marked code within the code // I want this specific code to be displayed second but I know its in the wrong spot. Here is the code [CODE] function show() { var myArray = new Array(); myArray[0] = document.getElementById('fullname').value; ' myArray[1] = document.getElementById('address').value; myArray[2] = document.getElementById('phone').value; myArray[3] = document.getElementById('email').value; //Code I want to display second in the textarea //var string = myArray.join("\n") //document.getElementById('textarea').value = string; document.writeln('Thank you for registering,' + ' ' + myArray[0] + '. Your membership will be confirmed by E-mail to ' + myArray[2] + "<br>"); document.writeln('Registration Details:') document.writeln("<br>") for (var i=0; i<myArray.length; i++) { document.write(myArray[i] + "<br>"); } } [\CODE] Thanks in advance Similar TutorialsI'm sorry if this question seem very basic but I just start learning javascript. I would like to display an image but not sure why it is not working. In a nutshell, here's my code Code: <html> <head></head> <body> <script type="text/javascript"> document.writeln("<img src=/"xMark.jpg /" width=25 height=25 >");</script> </body> </html> Not sure why this is not working but can someone see my error. <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>HomeWork3Part2</title> <script type="text/javascript"> function finalPay(grossPay){ var federalTax = num.tofixed(2)(grossPay * (.31)); var stateTax = num.tofixed(2)(grossPay * (.08)); var localTax = num.tofixed(2)(grossPay * (.02)); var finalPay = (grossPay - (federalTax + stateTax + localTax)); return finalPay; } </script> </head> <body> <script type="text/javascript"> var grossPay = parseInt(prompt("Enter your Gross Pay Amount", "400")); document.writeln(finalPay(grossPay) + " Is your amount of your check after taxes are taken out"); </script> </body> </html> Hi, I need to open a PDF file via a web page. Basically, I want to have a textbox where I type in a filename and then click submit and it will open that document. For example, I need to open a PDF document... I need to have a text box where I can input "test1" for example, click "GO" and it will add the "C:/test/" + textbox value + ".pdf" and open it in the browser. I could do it in PHP but this is going to run on a local machine with no serverside so I assume JS will be the way forward. Any ideas? Many Thanks MJFCAD I have created a small file where I check if the passwords entered in the code match or not, if they do not match, the button that links to the next webpage should not work(allow them to go to the next wepage). ive tried various websites to help me try and solve this but I just dodont understand what they are doing. I'm very new to programming btw here is some example code: Code: !doctypeHTML <html> <script> //lets just pretend that ive already done all the .getelement by id stuff to get the code things //suppose the person did not write anything in the form, an error will get pushed(alerted basically) if(!form['password'].value) error.push('Missing Password'); <form> <label>Password<br><input type="password" name="password"></label> <label>Confirm Password<br><input type="password" name="confirm"</label> </form> </html> now how would I make the submit button not submit if there are errors? please be as simple as possible, I am new to this! I need to validate some fields on a form. I have cut the script down to bare minimum to try to isolate the errors but no luck. This is the script Code: function verifyimages(){ var errorstatus = "groovey"; var errormsg = ""; var str = ''; var elem = document.getElementById('salespageform').elements; for(var i = 0; i < elem.length; i++) { document.write("file type: " + elem[i].type + " <br>" ); document.write(" value: " + elem[i].value + " <br>"); } if (errorstatus=="groovey"){ document.salespageform.submit(); return true; } else { alert(errormsg+"\n You can only upload a gif, jpg, jpeg or prn image"); return false; } } The form that calls this code has about 30 fields some text, some file, some hidden. When I replace the section that say Code: document.write("file type: " + elem[i].type + " <br>" ); document.write(" value: " + elem[i].value + " <br>"); with this Code: for(var i = 0; i < elem.length; i++) { str += "<b>Type:</b>" + elem[i].type + "  "; str += "<b>Name:</b>" + elem[i].name + " "; str += "<b>Value:</b><i>" + elem[i].value + "</i> "; str += "<BR>"; } document.write(str); it works fine. But what I really want to do is check that if the file type is "file" that the value is a jpeg, prn or gif. I know how to do that with regular expressions but I am getting errors -- different ones in IE and Firebox. So the first code presented throws this error in IE It displays the first file type and then errors with the message PERMISSION DENIED I also tried the following code in the for loop Code: for(var i = 0; i < elem.length; i++) { if (elem[i].type == "file"){ document.write('its a file'); } } that throws the error message that document.salespageform.submit is undefined these "seem" to work in firefox Any help is appreciated Hi there! I've been trying to edit this script but it continues to open my slideshow images into new tabs. I would like that the images on the slideshows when clicked they will open in the same tab. How can I do that? Thanks in advanced Here is the script I am using <a href="javascript:gotoshow()"><img src="http://imgkk.com/i/hPnvq8.jpg"target="_self""_innerframe" name="slide" border=1 width=375 height=275></a> <script> <!-- //configure the paths of the images, plus corresponding target links slideshowimages("http://imgkk.com/i/hPnvq8.jpg","http://imgkk.com/i/blxJnL.jpg","http://imgkk.com/i/7UzTr8.jpg","http://imgkk.com/i/_CP_mA.jpg") slideshowlinks("http://www.pimpthatfood.com/ptf-articles","http://www.pimpthatfood.com/food-forum","http://www.pimpthatfood.com/ptf-store","http://www.pimpthatfood.com/healthips") //configure the speed of the slideshow, in miliseconds var slideshowspeed=5000 var whichlink=0 var whichimage=0 function slideit(){ if (!document.images) return document.images.slide.src=slideimages[whichimage].src whichlink=whichimage if (whichimage<slideimages.length-1) whichimage++ else whichimage=0 setTimeout("slideit()",slideshowspeed) } slideit() //--> </script> hello everybody, I need help about, I need to change the result to opening a url page. This script results in a value and I need the result to be open a url page. Can anyone help me?? <SCRIPT language="Javascript"> nome = new Array(4); nome[0] = new Array(4); nome[1] = new Array(4); nome[2] = new Array(4); nome[3] = new Array(4); nome[0][0]="1500"; nome[0][1]="1250"; nome[0][2]="1300"; nome[1][0]="800"; nome[1][1]="850"; nome[1][2]="900"; nome[2][0]="500"; nome[2][1]="520"; nome[2][2]="540"; nome[3][0]="400"; nome[3][1]="356"; nome[3][2]="234"; function affi() { document.form.txt.value=nome[document.form.liste.selectedIndex][document.form.taille.selectedIndex]; } </SCRIPT> <form name="form" class="texto" > Choose the article : <select name="liste"> <option>Camisas <option>Polos <option>T-shirts <option>base corporal </select> <br> Choose the size: <select name="taille"> <option>T. Small <option>T. Médium <option>T. Large </select> <br> <input type="button" value="Obter preço" onClick="affi(this.form)" name="button"> <br> <br> <input type="TEXT" name="txt"> </form> Thank's in advance rui Hi I have a requirement. I have a page that has a number of blinds. When the user clicks on any one of the blinds, it should align itself to the center of the page. I tried this approach var sHeight = screen.height/2; document.body.scrollTop = sHeight - (sHeight - clientYvalue); blindPosition = clientYvalue; but it is not working. Any help would be appreciated. Thanks Vamsi This used to work and suddenly it does not work in IE. Here's the function Code: function pdfWindow(loc) { if(loc == "#RefQuide") { location.href = loc; } else { // The window attributes var window_attribs = "height=650,width=850,resizable=yes,scrollbars=yes"; window.open(loc,"PDF",window_attribs); } } Here's part of the HTML Code: <form name="myForm"> <select name="hypercomList"> <option value="/CWRWeb/pdf/HypercomT4000.pdf">Hypercom T4000 </option> <option value="/CWRWeb/pdf/HypercomT4100.pdf">Hypercom T4100 </option> </select> <input type="button" value="Go!" onclick="pdfWindow(myForm.hypercomList.options[myForm.hypercomList.selectedIndex].value)"> </form> Any ideas why it would open a blank page instead of the PDF? Works ok in FF. Hi, I am using Javascript to display options in a form with 2 dropdown lists. However, despite using the rel="nofollow" target='_self', the result opens in a new window. Help would be much appreciated. Code: // JavaScript Document function setOptions(chosen) { var selbox = document.ChronoContact_course_finder.opttwo; selbox.options.length = 0; if (chosen == ' ') { selbox.options[selbox.options.length] = new Option('Choose Option',' '); } if (chosen == '85') { selbox.options[selbox.options.length] = new Option('ITEC Beauty Specialist Diploma','index.php?option=com_content&view=article&id=49&Itemid=68',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Professional Makeup','index.php?option=com_content&view=article&id=57&Itemid=76',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Fashion Catwalk & Photographic Makeup Course','index.php?option=com_content&view=article&id=67&Itemid=91',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Bridal Makeup Course','index.php?option=com_content&view=article&id=68&Itemid=92',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Special Effects Makeup','index.php?option=com_content&view=article&id=56&Itemid=77',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Gel Nails Course','index.php?option=com_content&view=article&id=65&Itemid=88',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Acrylic Nails Course','index.php?option=com_content&view=article&id=66&Itemid=89',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Spray Tanning Course','index.php?option=com_content&view=article&id=55&Itemid=73',rel="nofollow" target='_self'); } if (chosen == '69') { selbox.options[selbox.options.length] = new Option('ITEC Holistic Massage Course','index.php?option=com_content&view=article&id=51&Itemid=2',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=78',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Indian Head Massage Course','index.php?option=com_content&view=article&id=60&Itemid=79',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Reflexology Diploma','index.php?option=com_content&view=article&id=64&Itemid=87',rel="nofollow" target='_self'); } if (chosen == '80') { selbox.options[selbox.options.length] = new Option('ITEC Teaching Diploma','index.php?option=com_content&view=article&id=61&Itemid=81',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('FETAC Train The Trainer Level 6','index.php?option=com_content&view=article&id=63&Itemid=86',rel="nofollow" target='_self'); } if (chosen == '83') { selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=90',rel="nofollow" target='_self'); } } And the HTML... Code: <div class="form_item"> <div class="form_element cf_heading"> <h1 class="cf_text">course finder</h1> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_dropdown"> <label class="cf_label" style="width: 200px;">Step 1: Choose type of course</label> <select name="optone" class="cf_inputbox" size="1" onchange="setOptions(document.ChronoContact_course_finder.optone.options[document.ChronoContact_course_finder.optone.selectedIndex].value);"> <option value=" " selected="selected">Choose Option</option> <option value="85">Beauty courses</option> <option value="69">Complimentary courses</option> <option value="80">Teaching courses</option> <option value="83">Fitness courses</option> </select> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_dropdown"> <label class="cf_label" style="width: 200px;">Step 2: Choose a subject</label> <select size="1" name="opttwo" class="cf_inputbox" > <option value=" " selected="selected">Choose Option</option> </select> <!--<input type="button" name="go" value="Value Selected" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);">--> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_button"> <input type="submit" name="go" value="search" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);"> </div> <div class="cfclear"> </div> </div> Many thanks, Paul Hi, I am using javascript function for refreshing html page. I have used [window.location.reload(true);] method to reload page from server. This code works if i use it by using Link/button etc. For Example: <input type="button" value="Refresh" onclick="window.location.reload(true);" /> But i want to refresh page when page loads. For Example: <body onload = "window.location.reload(true);> But this time, page reloads in an infinite loop. i don't know why... I have also used following function (against body onLoad) to reload and then stop, but this also does'nt work. function doLoad(){ var timeoutId = setTimeout( window.location.reload(true), 1000 ); window.clearTimeout(timeoutID); } Is there a way to stop reloading page after one refresh ? Thanks... Is there anyway to stop the page 'jumping to the top' when using a link like the below? Code: <a href="#" onClick="arrangeCards();">blah</a> .. I just want it to stay in the same position on the page & not jump to the top of the page every time a link like that is clicked. Cheers! I'm attaching my php test file but this is a JS problem. When I scroll down in the web page and the meta refresh hits, in Windows Safari and IE6/7/8 browsers, the web page re-positions back to the top. In Opera and FF the page refreshes but it stays where it is. Can someone look at my test script and see why it is not working in IE and Win Safari? My goal is to have the web page not re-position to the top on the auto refresh. Thanks... when i click on submit button, all the data in form will be inserted into my db. but when i click on refresh the form will be submitted again .. how can i prevent this?
hi everyone, Here's part of the codes I got from our website. Right now, when someone wants to register on our website, they have to put into the Captcha after they finish all the other information. If the captcha is empty, there would be an alert; if it's wrong, the page would be refreshed, and there would be another alert, and at the same time, all the information would be lost and they have to fill them again. Now the question is, how can I stop the page refreshing itself? All I need is an alert and then you could retype the captcha without losing the other information. Thank you in advance for your advice! <script type="text/javascript"> function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); } function validateForm() { var okSoFar=true with (document.practitioner_profile) { if (firstname.value=="" && okSoFar) { okSoFar=false alert("Please enter your first name.") firstname.focus() } if (lastname.value=="" && okSoFar) { okSoFar=false alert("Please enter your last name.") lastname.focus() } //some other things here... if (verify_code.value=="" && okSoFar) { okSoFar=false alert("Please enter your security code.") verify_code.focus() } if (okSoFar==true) submit(); } } //here's the submit button in the html code, <div class="practsubmit"> <div class="signupform"><h4>* Security Code:</h4> <p>Please type in what you see in the box below and press submit. Characters are case-sensitive.</p></div> <div class="signupform"><img id="captcha" src="index.php?option=com_egbcaptcha&width=150&height=50&characters=5" /><br /><input id="verify_code" name="verify_code" type="text" /></div> <input type="button" class="button" value="Send" name="B1" ONCLICK="javascript:validateForm()"> <input type="reset" class="button" value="Clear" name="clear"> </div> Hi. I've just finished up a web design I've been working on and of course it looks and works great in FF, but has problems in IE. My question is, how do you see what's wrong in IE? I know how to fix the html/css but how do I see what's going wrong with the javascript and php? Is there link in IE where I can see the errors? Thanks in advance. Hello there I've been searching and searching but couldn't make this script stop reseting after reloading the page. The scripts counts down some timers every x hours but the problem is that each time the page is reloaded the timer resets. Could anyone help me here how to keep the countdown going even if i reload page? thanks in advance I call the timers with. Example Timer 8: >div... etc id="timeLeft8" Code: <script type="text/javascript"> var events = new Array(); events[1]={name: 'Blood Castle:', startUp: new Array( {hour:0,minute:25}, {hour:2,minute:25}, {hour:4,minute:25}, {hour:6,minute:25}, {hour:8,minute:25}, {hour:10,minute:25}, {hour:12,minute:25}, {hour:14,minute:25}, {hour:16,minute:25}, {hour:18,minute:25}, {hour:20,minute:25}, {hour:22,minute:25} )} events[2]={name: 'Devil Squa ', startUp: new Array( {hour:1,minute:55}, {hour:3,minute:55}, {hour:5,minute:55}, {hour:7,minute:55}, {hour:9,minute:55}, {hour:11,minute:55}, {hour:13,minute:55}, {hour:15,minute:55}, {hour:17,minute:55}, {hour:19,minute:55}, {hour:21,minute:55}, {hour:23,minute:55} )} events[3]={name: 'Chaos Castle:', startUp: new Array( {hour:0,minute:55}, {hour:2,minute:55}, {hour:4,minute:55}, {hour:6,minute:55}, {hour:8,minute:55}, {hour:10,minute:55}, {hour:12,minute:55}, {hour:14,minute:55}, {hour:16,minute:55}, {hour:18,minute:55}, {hour:20,minute:55}, {hour:22,minute:55} )} events[4]={name: 'Red Dragon:', startUp: new Array( {hour:0,minute:0}, {hour:2,minute:0}, {hour:4,minute:0}, {hour:6,minute:0}, {hour:8,minute:0}, {hour:10,minute:0}, {hour:12,minute:0}, {hour:14,minute:0}, {hour:16,minute:0}, {hour:18,minute:0}, {hour:20,minute:0}, {hour:22,minute:0} )} events[5]={name: 'Gold Invasion:', startUp: new Array( {hour:0,minute:0}, {hour:2,minute:0}, {hour:4,minute:0}, {hour:6,minute:0}, {hour:8,minute:0}, {hour:10,minute:0}, {hour:12,minute:0}, {hour:14,minute:0}, {hour:16,minute:0}, {hour:18,minute:0}, {hour:20,minute:0}, {hour:22,minute:0} )} events[6]={name: 'White Wizard:', startUp: new Array( {hour:0,minute:0}, {hour:2,minute:0}, {hour:4,minute:0}, {hour:6,minute:0}, {hour:8,minute:0}, {hour:10,minute:0}, {hour:12,minute:0}, {hour:14,minute:0}, {hour:16,minute:0}, {hour:18,minute:0}, {hour:20,minute:0}, {hour:22,minute:0} )} events[7]={name: 'Blue:', startUp: new Array( {hour:0,minute:40}, {hour:1,minute:40}, {hour:2,minute:40}, {hour:3,minute:40}, {hour:4,minute:40}, {hour:5,minute:40}, {hour:6,minute:40}, {hour:7,minute:40}, {hour:8,minute:40}, {hour:9,minute:40}, {hour:10,minute:40}, {hour:11,minute:40}, {hour:12,minute:40}, {hour:13,minute:40}, {hour:14,minute:40}, {hour:15,minute:40}, {hour:16,minute:40}, {hour:17,minute:40}, {hour:18,minute:40}, {hour:19,minute:40}, {hour:20,minute:40}, {hour:21,minute:40}, {hour:22,minute:40}, {hour:23,minute:40}, {hour:24,minute:40} )} events[7]={name: 'Hide&Seek:', startUp: new Array( {hour:0,minute:42}, {hour:1,minute:22}, {hour:2,minute:32}, {hour:3,minute:42}, {hour:4,minute:52}, {hour:6,minute:02}, {hour:7,minute:12}, {hour:8,minute:22}, {hour:9,minute:32}, {hour:10,minute:42}, {hour:11,minute:52}, {hour:13,minute:02}, {hour:14,minute:12}, {hour:15,minute:22}, {hour:16,minute:32}, {hour:17,minute:42}, {hour:18,minute:52}, {hour:20,minute:02}, {hour:21,minute:12}, {hour:22,minute:22}, {hour:23,minute:32} )} events[8]={name: 'Sky:', startUp: new Array( {hour:1,minute:5}, {hour:4,minute:5}, {hour:7,minute:5}, {hour:10,minute:5}, {hour:13,minute:5}, {hour:16,minute:5}, {hour:19,minute:5}, {hour:23,minute:5} )} events[9]={name: 'Boss Attack:', startUp: new Array( {hour:1,minute:50}, {hour:4,minute:50}, {hour:7,minute:50}, {hour:10,minute:50}, {hour:13,minute:50}, {hour:16,minute:50}, {hour:23,minute:50} )} events[10]={name: 'Happy Hour:', startUp: new Array( {hour:5,minute:5}, {hour:2,minute:5}, {hour:8,minute:5}, {hour:11,minute:5}, {hour:14,minute:5}, {hour:17,minute:5}, {hour:20,minute:5}, {hour:0,minute:5} )} events[11]={name: 'Hit and Up:', startUp: new Array( {hour:0,minute:20}, {hour:2,minute:20}, {hour:5,minute:20}, {hour:8,minute:20}, {hour:11,minute:20}, {hour:14,minute:20}, {hour:20,minute:20} )} events[12]={name: 'Raklion:', startUp: new Array( {hour:0,minute:15}, {hour:3,minute:15}, {hour:6,minute:15}, {hour:9,minute:15}, {hour:12,minute:15}, {hour:15,minute:15}, {hour:18,minute:15}, {hour:21,minute:15} )} events[13]={name: 'Moss:', startUp: new Array( {hour:3,minute:35}, {hour:7,minute:35}, {hour:11,minute:35}, {hour:15,minute:35}, {hour:19,minute:35}, {hour:23,minute:35} )} events[14]={name: 'Illusion Temple:', startUp: new Array( {hour:0,minute:25}, {hour:1,minute:25}, {hour:2,minute:25}, {hour:3,minute:25}, {hour:4,minute:25}, {hour:5,minute:25}, {hour:6,minute:25}, {hour:7,minute:25}, {hour:8,minute:25}, {hour:9,minute:25}, {hour:10,minute:25}, {hour:11,minute:25}, {hour:12,minute:25}, {hour:13,minute:25}, {hour:14,minute:25}, {hour:15,minute:25}, {hour:16,minute:25}, {hour:17,minute:25}, {hour:18,minute:25}, {hour:19,minute:25}, {hour:20,minute:25}, {hour:21,minute:25}, {hour:22,minute:25}, {hour:23,minute:25}, {hour:24,minute:25} )} events[15]={name: 'Castle Deep:', startUp: new Array( {hour:1,minute:25}, {hour:7,minute:25}, {hour:13,minute:25}, {hour:19,minute:25} )} events[16]={name: 'CryWolf:', startUp: new Array( {hour:1,minute:45}, {hour:4,minute:45}, {hour:7,minute:45}, {hour:10,minute:45}, {hour:13,minute:45}, {hour:16,minute:20}, {hour:19,minute:45}, {hour:22,minute:45} )} var curTime=1336998502 var dateTime=1336953600 function timeLeft(i){ for(j in events[i].startUp){ tmp=events[i].startUp[j].hour*3600+events[i].startUp[j].minute*60 if(dateTime+tmp>curTime){ return dateTime+tmp-curTime; } } tmp=events[i].startUp[0].hour*3600+events[i].startUp[0].minute*60 return dateTime+86400+tmp-curTime; } function getFormatedLeftTime($seconds){ $second = $seconds % 60; $minutes = parseInt(($seconds / 60) % 60); $hour = parseInt(($seconds / 3600) % 24); $days = parseInt($seconds / (24 * 3600)); $ret = ''; if ($days > 0) if ($days == 1) $ret += '1 day '; else $ret += $days + ' days '; if ($hour > 0){ if ($hour < 10) $hour = '0' + $hour; $ret += $hour + ':'; }else if ($days > 0) $ret += '00:'; if($minutes < 10) $minutes = '0' + $minutes; $ret += $minutes + ':'; if ($second < 10) $second = '0' + $second; $ret += $second; return $ret; } function updateTimes(){ curTime++; for (i in events){ document.getElementById("timeLeft"+i).innerHTML=getFormatedLeftTime(timeLeft(i)); } } for(i in events) document.getElementById("eventList").innerHTML+="<div style='float:right; color: #FFFF00;' id='timeLeft"+i+"'>"+getFormatedLeftTime(timeLeft(i))+"</div><div style=\"color: #00FFFF;\"><strong>"+events[i].name+"</strong></div>"; setInterval("updateTimes()", 1000); </script> I have a set of tabs that are set with an href that adds a query string to the url such as "?t=1", meaning the first tab is selected. Technically it works just fine but every time I click a tab it reloads the page and I'm not entirely sure how to stop this. I'm using a jquery plugin to handle the query strings. Here's the plugin. Here's the piece of the code that matters: Code: var url = location.search; var tab = $.query.get('t'); init(tab); function init(tab){ $("div.tab").hide(); //hides all the content boxes related to the tabs $("div#tab"+tab).fadeIn("fast"); //Shows the selected tab's content box setInactive(); //Styles unselected tabs setActive(tab); //Styles selected tab } Any help would be greatly appreciated. I've written the following html, <html> <head> <script type="text/javascript"> function createpage(){ var first = document.getElementById('first').value var second = document.getElementById('second').value var third = document.getElementById('third').value var j = window.open('random'); var new_page = '<html><head><script type="text/javascript">function open_win() { window.open(first) window.open(second) window.open(third) } </script></head><body onLoad = "open_win()"></body></html>'; j.document.write(new_page); j.document.close(); } </script> </head> <body> <form action=""> <p> First Link: <input type="text" id="first" name="first"/> Second Link: <input type="text" id="second" name="second"/> Third Link: <input type="text" id="third" name="third"/> <input type=BUTTON value="Submit" name="mySubmit" onClick="createpage();return false;"> </p> </form> </body> </html> With the intention to eventually implement it into a website that "mashes" several URLs together into a tinyurl that, upon being opened, creates several tabs of the content the creator wanted in the single URL. Does that make sense? In order to best do this I figured a page with a random character string (I haven't yet implemented this part, for now 'random' holds the place of the new page/link) would have to be created that would launch all the tabs and then close itself. Here's what it should do... 1) User enter 3 URLs into three forms: First Link: <input type="text" id="first" name="first"/> Second Link: <input type="text" id="second" name="second"/> Third Link: <input type="text" id="third" name="third"/> 2) User clicks Submit button that calls "createpage()" function that's declared in the <head>er. The first part of this function declares the links that were inputted as variables first, second, and, third. <script type="text/javascript"> function createpage(){ var first = document.getElementById('first').value var second = document.getElementById('second').value var third = document.getElementById('third').value 3) "createpage()" function then declares a new window named 'random' to variable j (I have random.html stored in the same folder as this project. It is empty.) var j = window.open('random') 4) Next "createpage()" creates a variable that stores a full page's html code that includes a script that launches each link individually with window.open(). var new_page = '<html><head><script type="text/javascript">function open_win() { window.open(first) window.open(second) window.open(third) } </script></head><body onLoad = "open_win()"></body></html>'; 5) "createpage()" writes the code (stored in variable 'new_page') to document 'random' with j.document.write(new_page); 6) "createpage()" closes the document. |