JavaScript - Scroll To Parent Frame When You Can't Control It
Hi,
I have searched the net extensively for a js link code that will scroll to the top of the parent frame. So, link is in iframe within a parent frame that I can't control. Therefore I cannot place any 'a name' attribute in any link in the parent frame. But would like to scroll to the top once the button in my iframe is clicked. I have used most scroll, document scroll to parent etc js functions but none of them scroll to top of parent page and some require a name to be placed in parent this is my simple link <a href="#">go to top</a> Please give me a solution if you have one. please take note that I can't place any code in parent frame. Similar TutorialsThe following script will take the option parameter from the page URL and scroll the page to the element which has the matching ID. For example: mypage.html?element3 will cause it to scroll to the element which has an id="element3" when the page loads. Code: <html><head><title></title> <script type="text/javascript"> function OptionScroll(){ if (location.search.length > 0){ LocnId=unescape(location.search.substring(1)) scrollLocn = document.getElementById(LocnId).offsetTop document.body.scrollTop = scrollLocn } } </script> </head> <body onload="OptionScroll()"> ...etc.... This works fine. Now for the next step, I want to be able to do this from a script embedded in an iframe. In other words, when the page loads, the iframe will load and a script within the iframe executes taking the parameter from the parent page's URL, and then scrolls the parent page to the element with the matching ID. Is it possible to do this? Help will be greatly appreciated! Situation: I have a very long page divided into many sections vertical-wise marked by bookmarks, say pageX.html#s1 to s10. I need to show the section inside an iframe (iFrame1) on the mainpage (mainpage.html). I am thinking of having 4 buttons, sitting on the mainpage, to help navigate between these sections on pageX, namely NEXT, PREVIOUS, TOP, END. condition of the frame, fixed width/height, no scroll, no border. Very new to javascript but need this code to make a page work for BIZ. Thank you in advance for anyone kind enough to point the right direction! Hi. I have a question about java script code. I'm creating a website with frames. Within the main page frame, there are tables in the main content page. When I created the website, it fit perfectly in the browser window of my smaller laptop. I just checked it out on my old G5 and the images/pages are too big and either cut off or scroll bars appear (which is not what I want) So I wanted to know what code I put in my files and where to put it? Also, what pages does it need to be in? the main frame index page? the specific pages that fit within the frames? some are images that load in the frames? would i need to create an .html for those and then have the .jpg load so that it can be resized? I need the main page to be resized to fit the browser as well as the pages in the frames to fit. Can you help? Thanks I' am trying to do a frame by frame animation, lik an animated gif. I am using svg (vector graphics) and IE9 has native support for svg. The code functions in every other browser but IE9 plays the animation once then nothing. If you would like to try and not have svg files you can use whatever gif,jpg or png just put an img-tag where i have embed. Code: <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Animation</title> <style type="text/css"> /*One div per image all uses this class*/ .eyesPos { position:absolute; width:80px; height:50px; z-index:1; left: 0px; top: 0px; } #eye_wrapper{/*This is a master div for easy placement of the others*/ position:absolute; width:80px; height:50px; z-index:2; left: 275px; top: 200px; } </style> <script> var eyes=["a","b","c","d"];//Image id in this array var startAnim=setInterval(visaOga,100);//Animation speed function visaOga(){ document.getElementById(eyes.splice(0,1)).style.display="block"; if(eyes.length==0){ document.getElementById("a").style.display="none"; document.getElementById("b").style.display="none"; document.getElementById("c").style.display="none"; dBort = function(){ document.getElementById("d").style.display="none"; eyes=["a","b","c","d"]; } setTimeout(dBort,1500);//So last image is shown 1.5 sec return;//Aborts - dBort -. Sequence can start over if(document.getElementById("d").style.display=="none"){ startAnim;//Strts sequence if last image invisible } } } </script> </head> <body> <!--Images in own div invisible at start--> <div id="eye_wrapper"> <div class="eyesPos" id="a" style= display:none;> <embed src="0.svg" width="80" height="50" /> </div> <div class="eyesPos" id="b" style= display:none;> <embed src="1.svg" width="80" height="50" /> </div> <div class="eyesPos" id="c" style= display:none;> <embed src="2.svg" width="80" height="50" /> </div> <div class="eyesPos" id="d" style= display:none;> <embed src="3.svg" width="80" height="50" /> </div> </div> </body> </html> guys help pls.. i need to pass the data in the textfields from the left frame to the textfields in the right frame of my frameset. (ex: dslnum of frame1 will be pass to txtDSLTN of frame2) frame1: http://www.mediafire.com/?hge1ws29mdhmu7e frame2: http://www.mediafire.com/?k83cb64wbpskw97 thanks in advance! Hello all, I have a page which has a form and also one iframe in the same. there is a button on the parent form. when the button is clicked, i am submitting the iframe and parent both. forms are getting submitted. but when i do print_r for iframe values, it is blank below is the code Parent page: Code: <? print "<pre>"; print_r($_POST); print "</pre>"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- function validate(){ document.getElementById('mainform').submit(); window.frames['iframe1'].document.forms[0].submit(); } //--> </SCRIPT> <BODY> <FORM METHOD=POST ACTION="" name='mainform' id='mainform'> <TABLE> <TR> <TD>Name</TD> <TD><INPUT TYPE="text" NAME="Name_VC"></TD> </TR> <TR> <TD>Address</TD> <TD><INPUT TYPE="text" NAME="Address_VC"></TD> </TR> <TR> <TD colspan=2><INPUT TYPE="button" name="proceed" value="Save" onClick="validate();"></TD> </TR> </TABLE> </FORM> <iframe src="test1.php" id='iframe1'></iframe> </BODY> </HTML> iframe page : test1.php Code: <? print "<pre>"; print_r($POST); print "</pre>"; ?> <form name='mainform2' id='mainform2' method='post' action=''> Roll number : <INPUT TYPE="text" NAME="Rollnum" value=''> Age: <INPUT TYPE="text" NAME="Age_IN" value=''> </form> Please tell me what is my mistake or how can i achieve values of all 4 fields Million thanks I have a page called answersheet.html which I am popping up using a function called NewWindow; Code: <a href="javascript:myVoid()" onclick="NewWindow('/images/101online/practicetest1/listensubtest1/answersheet.html','PopUp','625','400','no',''); return true;"> It works fine. answersheet.html consists of two frames, the top frame containing a button with onclick="myprint()" to print out the bottom frame: Code: <script type="text/javascript"> function myprint() { window.parent.bottom.focus(); window.print(); } </script> It does the job in Internet Explorer, but Firefox and Chrome only print the top frame with the print button! Is the function myprint() IE only coding? If so, what should I use? Hello everyone, I have a page. In that page is an iframe, lets name it 'A'. inside A there is another iframe 'B'. there is a link on that page which on click opens a popup. In that pop up, there is actually a document upload facility. Now i want that after every upload (onSubmit), iframe A should refresh. have done it many times but today its not working. Code: function validate() { (window.parent.opener.location.href)=(window.parent.opener.location.href); window.parent.opener.location.reload(true);// this is tried as well } Can some one please help. it always refreshes only B. Thanks Hey all, I have a script that limit characters and lines entered by users in a textarea.. i want instead of throwing that alert message to jump to the next line and the user can continue writing, here is the script: Code: <script type="text/javascript"> var alert_title='Input Restriction'; function limitTextarea(el,maxLines,maxChar){ if(!el.x) { el.x=uniqueInt(); el.onblur=function(){clearInterval(window['int'+el.x])} } window['int'+el.x]=setInterval(function(){ var lines=el.value.replace(/\r/g,'').split('\n'), i=lines.length, lines_removed, char_removed; if(maxLines&&i>maxLines){ alert('You can not enter\nmore than '+maxLines+' lines'); lines=lines.slice(0,maxLines); lines_removed=1 } if(maxChar){ i=lines.length; while(i-->0)if(lines[i].length>maxChar){ lines[i]=lines[i].slice(0,maxChar); char_removed=1 } if(char_removed) alert('You can not enter more\nthan '+maxChar+' characters per line') } if(char_removed||lines_removed) el.value=lines.join('\n') },50); } function uniqueInt(){ var num,maxNum=100000; if(!uniqueInt.a||maxNum<=uniqueInt.a.length)uniqueInt.a=[]; do num=Math.ceil(Math.random()*maxNum); while(uniqueInt.a.hasMember(num)) uniqueInt.a[uniqueInt.a.length]=num; return num } Array.prototype.hasMember=function(testItem){ var i=this.length; while(i-->0)if(testItem==this[i])return 1; return 0 }; </script> The HTML Code: <textarea onFocus="limitTextarea(this,5,40)" wrap="soft"></textarea> please help! I am trying to set up a form for paypal where the amount (cost) of the product is based on the currency chosen. I am trying to set this up using javascript which would submit the form and change the amount in the form. However, as a beginner, I am having some issues. This is what I have currently: Code: <html> <head> <script type="text/javascript"> function CalculateOrder(theform) { var currency = theform.currency_code.value; if (currency == "GBP") { theform.amount.value = "1.29" } else if (currency == "USD") { theform.amount.value = "1.99" } else if (currency == "EUR") { theform.amount.value = "1.39" } document.payform.submit(); } </script> </head> <body> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr " method="post" name="payform"> <input type="hidden" name="on0" value="Currency"> <select name="currency_code"> <option value="GBP" selected >GBP</option> <option value="USD">USD</option> <option value="EUR">EUR</option> </select> </p> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif " onClick="CalculateOrder(this.form)" alt="Make payments with PayPal - it's fast, free and secure!"> <input type="hidden" name="add" value="1"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="myemail@gmail.com"> <input type="hidden" name="item_name" value="My Prouct"> <input type="hidden" name="amount" value="0.00"> <input type="hidden" name="shipping" value="0"> <input type="hidden" name="no_shipping" value="1"> </form> </fieldset> </body> </html> The javascript is executed but clicking the image submits the form before the javascript runs and I am worried that the javascript may not run before the form is submitted so the amount would not be calculated - please help! I do not want to calculate the costs based on the exchange rate. I would really prefer (and also find it simpler) to just specify the cost in each currency. Thanks in advance! Sup gents. Excuse my tenaciously novice questions, but dont disparage just yet, im beginning to grasp how the mechanism behind the code words, in due part to your helpful suggestions Im in the last stages of the code. In this section i have added three methods, whose function is to direct access control over the ciphers i will be adding shortly. I firstly need for the methods to be working. What they do is, categorize the set of values inside the first array and give a set of names privileges. The three methods that deal with the access control are link(), secondgroup() and third group. Ive assigned that the first three names( link() ) can access all the ciphers, ie administrators, the next three names ( secondgroup() ) can only access the shift, permutation and vigenere ciphers and the rest ( thirdgroup() ) can access the other remaining ciphers. But ive added so much code at once that i overwhelmed myself and i now i cant figure out where ive gone wrong, be it in the syntax or the logic Code: <html> <head> <script type ="text/JavaScript"> var counter = 0; var counter2 = 0; var arraynumb = 0; var arraynumb2 = 0; var global; var array = ['Mohamad', 'Karim', 'Anthony', 'Rami', 'Natalia', 'Sarah', 'Samer', 'Violette', 'Plume', 'Sharshabil']; var array2 = ["1000", "1001", "1002", "1003", "1004", "1005", "1006", "1007", "1008", "1009"]; function pass(){ var searchKey = document.searchform.inputVal.value; for (var i = 0, len = array.length; i < len; i++){ if (array[i] == searchKey){ counter = 1; arraynumb = i; } } } function pass1(){ var searchKey2 = document.searchform.inputVal2.value; for (var i = 0, len = array2.length; i < len; i++){ if (array2[i] == searchKey2){ counter2 = 1; arraynumb2 = i; } } } function access() { if (counter == 1 && counter2 == 1 && arraynumb == arraynumb2) { window.alert("You may access the website"); global = 1; } else{ window.alert("You may not access the website"); global = 0; } } function link() { var searchKey3 = document.searchform.inputVal.value; if (global == 1 && (searchkey3 == array[0] || searchkey3 == array[1] || searchkey3 == array[2] )) { window.alert("You are an administrator, you may use all the ciphers"); } else window.alert("you are not signed in, please do so"); } function secondgroup() { var searchKey4 = document.searchform.inputVal.value; if (global == 1 && (searchkey4 == array[3] || searchkey4 == array[4] || searchkey4 == array[5] )) { window.alert("You are an ordinary user of class A, you may proceed to access the Shift, Vigenere and Permutation ciphers"); } else window.alert("You may not access this cipher"); } fucntion thirdgroup() { var searchKey5 = document.searchform.inputVal.value; if (global == 1 && (searchkey5 == array[6] || searchkey5 == array[7] || searchkey5 == array[8] || searchkey5 == array[9] )) { window.alert("You are an ordinary user of class B, you may proceed to access the Hill, Affine, Substitution and DES ciphers"); } else window.alert("You may not access this cipher"); } </script> </head> <body> <form name = "searchform" action = ""> <p>Enter username<br/> <input name = "inputVal" type = "text" size = "30"/> <input name = "search2" type = "button" value = "Search" onclick = "pass()"/> </p> <p>Enter password<br/> <input name = "inputVal2" type = "password" size = "30"/> <input name = "search" type = "button" value = "Search" onclick = "pass1()"/> <input name = "Access site" type = "button" value = "Access" onclick = "access()"/> <br/> <br/> <input name = "link to" type = "button" value = "Shift" onclick = "link();return secondgroup();" enabled=""/> <input name = "link to" type = "button" value = "Vigenere" onclick = "link();return secondgroup();" enabled=""/> <input name = "link to" type = "button" value = "Permutation" onclick = "link();return secondgroup();" enabled=""/> <input name = "link to" type = "button" value = "Hill" onclick = "link();return thirdgroup();" enabled=""/> <input name = "link to" type = "button" value = "Affine" onclick = "link();return thirdgroup();" enabled=""/> <input name = "link to" type = "button" value = "Substitution" onclick = "link();return thirdgroup();" enabled=""/> <input name = "link to" type = "button" value = "Des" onclick = "link();return thirdgroup();" enabled=""/> <br/> </p> <br/> <p></p> </form> </body> </html> Hi, Ok i want to do the following... I am using blogger and I have thousands of posts and each post topic has a specific image assigned to it but every now and then I like to change the image that is being displayed but then I have to go through thousands of posts to change the image URL and this takes super long to complete. I thought of an idea of using Javascript to control this so I need your help please.. I want to be able to have a JS that I can insert the URL's of each image required for the posts and assign an ID like a number or a name to them, then have a seperate JS script that I can insert in ALL my posts and assign the same number to each related post relating to the image ID... So if I need to change images then all I need to do is change the URL in the Javascript and it affects all the posts that contain this image... hope this makes sense.. Please help Thank you. I have seen code like this but it only randomizes the images but is the same concept, perhaps someone can just alter this code for me please... [CODE] <head> <script language="JavaScript"> <!-- var theImages = new Array() theImages[0] = 'http://lh5.ggpht.com/_MAclvGBXzj4/TEtvnlxvvrI/AAAAAAAABQw/N7UVoBvtjxU/s320/video34.png' theImages[1] = 'http://lh6.ggpht.com/_MAclvGBXzj4/TEIZlr5FE6I/AAAAAAAABKU/LoBdw7Kqf3w/s200/Inside-blogger-256.png' theImages[2] = 'http://3.bp.blogspot.com/_MAclvGBXzj4/TCHDY788QaI/AAAAAAAAAAU/SnWr-NP0dqE/s200/news.png' theImages[3] = 'http://3.bp.blogspot.com/_MAclvGBXzj4/TEwgs_hhcXI/AAAAAAAABQ4/JTX1mzmdQLU/s200/croatia-flag.GIF' theImages[4] = 'http://lh6.ggpht.com/_MAclvGBXzj4/TEtzAvpIEQI/AAAAAAAABQ0/RiLAfiUsCiA/s320/warning23.png' var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('<img src="'+theImages[whichImage]+'">'); } //--> </script> </head> <body> <script language="JavaScript"> <!-- showImage(); </script> </body> [CODE] I have an ASP.Net page that uses functions in a .js file. I'm trying to reset the values in the controls on the form. The script I'm using works for Text boxes, TextArea boxes, and Check boxes, but, doesn't work for Select-One (DropDownList) or Select-Multi (List) controls. Included is the code. I use the alert() call as troubleshooting to insure the code segment is entered and the control is identified. The SelectIndex of the control is not being set. When this code is hard coded on the page it works. Code: function ClearAllControls() { for (i = 0; i <= document.forms[0].length; i++) { doc = document.forms[0].elements[i]; switch (doc.type) { case 'text':doc.value = ''; break; case 'textarea':doc.value = ''; break; case 'checkbox':doc.checked = false; break; case 'select-one': doc.selectedindex = 0; alert(doc.name + " - " + doc.type) break; default:break;} } } edit::I guess I tried everything else before thinking of a toggle variable....seems to be working now I have an if clause that triggers died(); Quote: died() { monster.y=-100; //move element off canvas setTimeout("respawn()", 2500); } respawn() { //move monster to random location inside canvas monster.x = 32 + (Math.random() * (canvas.width - 64)); monster.y = 32 + (Math.random() * (canvas.height - 64)); } if(collision condition true) { died(); } This works but it sends setTimeout("respawn()",2500); about a dozen times, so 2.5 seconds later when it respawns it runs a dozen times and the monster flickers around the canvas before finding it's final destination. I've tried both a WHILE loop which WORKED initially but I couldn't get it to reset properly, it worked the first time it ran and that was it.... I tried an if() with a global variable called count so it would only be called if count was under 2 but it didn't work right.... I tried a for loop as well. But my main() function is running every 10ms, and it just triggers things so fast that it triggers things multiple times when I only want it to fire once.... pseudo of what I'm trying to do. If(collision) {died();} died(){ move char off viewable screen, delay 2.5 seconds before moving back onto screen at random location} Seems so simple......but when there's a collision, it sends died() every pixel as the 2 objects move across each other.....where I need it to only trigger died after the first collision is detected and stop checking for 2.5 seconds or the duration of the wait before showing back up on the screen.. so maybe I need a new function to call died which can only be called once.... All, I have some code on my page which changes images in a div without reloading the page. This works great, however my problem comes with I go through a couple images and the actual URL is still on the original image. Is there any way to change the URL when I click the image as well?? Thanks in advance. I've been trying to get a form to control iframes, but new to javascript I basically want to input the url from a form & display it in an iframe, but cant figure out how to link the url from the form to the iframe The code im using atm Code: <html> <head> <title> SearchLite v2 - search multiple sites at once</title> <STYLE TYPE="text/css"> .txt { BACKGROUND-COLOR: lavender; BORDER-BOTTOM-COLOR: lavender; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-COLOR: lavender; BORDER-LEFT-WIDTH: 0px; BORDER-RIGHT-COLOR: lavender; BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-COLOR: lavender; BORDER-TOP-WIDTH: 0px; HEIGHT: 22px; WIDTH: 599px; } .cellht { HEIGHT: 50px; } .cell { BACKGROUND-COLOR: lavender; } </STYLE> <script> function win() { frmlen = document.myform.elements.length; idiv=1; for (var icnt=0;icnt<frmlen;icnt++) { //loop thru all FORM elements and look for checkboxes which have been checked if (document.myform.elements[icnt].type=="checkbox" && document.myform.elements[icnt].checked) { //make IFRAME visible document.getElementById("f"+idiv).style.visibility = 'visible'; //make textbox that shows heading with name of site being searched, visible document.getElementById("t"+idiv).style.visibility = 'visible'; //build the URL strSite = document.myform.elements[icnt].value; strSearch= escape(document.myform.mytext.value); url = strSite + strSearch; //set SRC property of IFRAME to dynamically built URL document.getElementById("f"+idiv).src = url; //show only the domain name part of the URL dmn=url.substring(7); document.getElementById("t"+idiv).value= dmn.substring(0,dmn.indexOf("/")); idiv+=1; } } } function hide() { for (var icnt=1;icnt<13;icnt++) { //hide all IFRAME s document.getElementById("f"+icnt).style.visibility = 'hidden'; //hide all the camouflaged textboxes that display the title document.getElementById("t"+icnt).style.visibility = 'hidden'; } } </script> </head> //Form1 i want to use for the url ........... <form> Enter URL1: <input type="text" name="Enter Url" /> </form> //Form2 i want to use for the url ........... <form> Enter URL2: <input type="text" name="Enter Url" /> </form> <body onload="hide()"> <form method=post action="" name="myform"> <table border=0 align='center'> <tr><td colspan=3 height='30%'><font size="5">SEARCH</font><i><font size="5" color="blue">LITE</font></i> v2 -search multiple sites at once and view results on a single page </td><td colspan=2> </td></tr> <tr > <td COLSPAN=3 ><input type="text" name="mytext" size="55"></td> <td COLSPAN=3><input type="button" value="Find" onClick="win()"> <input type="reset" value="Reset" onclick="hide()"> <a href="mailto:dotnut@hotmail.com">Feedback</a></td> </tr> <tr > //Want to change the value= replaced by the value in the form <td class="cell"><input type="checkbox" name="1" value="http://www.google.com/search?hl=en&btnG=Google+Search&q=">Google</td> <td class="cell"><input type="checkbox" name="2" value="http://www.dictionary.com/search?q=">Dictionary</td> <tr><td COLSPAN=5 HEIGHT='50' CLASS='cellht'><input type='text' id='t1' class='txt'></td></tr> <tr><td COLSPAN=5><IFRAME id='f1' FRAMEBORDER=1 SCROLLING='yes' WIDTH=600 HEIGHT=360></IFRAME><br></td></tr> <tr><td COLSPAN=5 CLASS='cellht'><input type='text' id='t2' class='txt' ></td></tr> <tr><td COLSPAN=5><IFRAME id='f2' FRAMEBORDER=1 SCROLLING='yes' WIDTH=600 HEIGHT=360></IFRAME><br></td></tr> </table> </form> </body> </html> thnx I have written JS , in which I used activex control which does not work on mozila , anyone has idea to to same thing without activex , here is code which just upload the textfile contains on html page . <html> <head> <script type="text/javascript" language="javascript"> function Read() { var Scr = new ActiveXObject("Scripting.FileSystemObject"); var CTF = Scr .OpenTextFile("J:\\Users\\Karimkhan\\Desktop\\2011-03-01.txt", 1, true); data = CTF .ReadAll(); document.write("<pre>" + data + "<pre>"); //alert(data); CTF .Close(); } </script> </head> <body onLoad="Read()"> </body> </html> can anyone tell me how to use jquery with asp.net web user control? Thanks in Advance Regards Salman Ansari I've got a style control for my website where the user can select text color and background color. Cookies then remember the selections. The problem I have is when you select a text color the background color is changed instead of the text color. After page refresh both the text and background colors are correct. The error console reports a few errors in each js script. The errors all say 'sel is undefined' on line 7. html: Code: <!DOCTYPE html> <html lang="en"> <head> <title>Style Control</title> </head> <body> <p><b>Style Control</b></p> <p>Text color: (Broke - Sets bg color insted, works after page refresh)</p> <form onsubmit="return false;" action=""> <script type="text/javascript" language="JavaScript" src="text_color.js"></script> <select name="color_select1" size="1" onchange="return setColor(this, global_name1)"> <option style="background-color: white;" value="white">white</option> <option style="background-color: black; color: white;" value="black">black</option> <option style="background-color: seagreen;" value="seagreen">seagreen</option> <option style="background-color: springgreen;" value="springgreen">springgreen</option> <option style="background-color: royalblue;" value="royalblue">royalblue</option> <option style="background-color: skyblue;" value="skyblue">skyblue</option> </select> </form> <br /><br /> <p>Background color:</p> <form onsubmit="return false;" action=""> <script type="text/javascript" language="JavaScript" src="bg_color.js"></script> <select name="color_select2" size="1" onchange="return setColor(this, global_name2)"> <option style="background-color: white;" value="white">white</option> <option style="background-color: black; color: white;" value="black">black</option> <option style="background-color: seagreen;" value="seagreen">seagreen</option> <option style="background-color: springgreen;" value="springgreen">springgreen</option> <option style="background-color: royalblue;" value="royalblue">royalblue</option> <option style="background-color: skyblue;" value="skyblue">skyblue</option> </select> </form> </body> </html> </body> </html> text_color.js : Code: var global_name1 = 'tcolor'; // function getColor(sel, cookie_name) { var cookie_value = getCookie(cookie_name); if (!cookie_value) cookie_value = 'black'; document.body.style.color = cookie_value; var opt = sel.options; var x, len = sel.length; for (x=0; x<len; x++) { if (opt[x].value == cookie_value) { opt[x].selected = true; break; } } return true; } getColor(document.forms[0].color_select1, global_name1); // function setColor(sel, cookie_name) { var opt = sel.options[sel.selectedIndex].value; var oneDay = 24 * 60 * 60 * 1000; var oneYear = 365 * oneDay; var expDate = new Date(); expDate.setTime(expDate.getTime() + oneYear); setCookie(cookie_name, opt, expDate); return getColor(sel, cookie_name); } // ---------------------------------------- // function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function setCookie(name, value) { var argv = setCookie.arguments; var argc = setCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function delCookie(name) { exp = new Date(); exp.setTime(exp.getTime() - (24*60*60*1000)); var cval = getCookie(name); cval = (cval == null) ? "" : cval; document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } bg_color.js : Code: var global_name2 = 'bgcolor'; // function getColor(sel, cookie_name) { var cookie_value = getCookie(cookie_name); if (!cookie_value) cookie_value = 'white'; document.body.style.backgroundColor = cookie_value; var opt = sel.options; var x, len = sel.length; for (x=0; x<len; x++) { if (opt[x].value == cookie_value) { opt[x].selected = true; break; } } return true; } getColor(document.forms[0].color_select2, global_name2); // function setColor(sel, cookie_name) { var opt = sel.options[sel.selectedIndex].value; var oneDay = 24 * 60 * 60 * 1000; var oneYear = 365 * oneDay; var expDate = new Date(); expDate.setTime(expDate.getTime() + oneYear); setCookie(cookie_name, opt, expDate); return getColor(sel, cookie_name); } // ---------------------------------------- // function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function setCookie(name, value) { var argv = setCookie.arguments; var argc = setCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function delCookie(name) { exp = new Date(); exp.setTime(exp.getTime() - (24*60*60*1000)); var cval = getCookie(name); cval = (cval == null) ? "" : cval; document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } Many thanks for any help. Hi. I'll would like to know how can I control a swf with a FLVPlayback, that it's reading a movie from my server, with Javascript. check the link. it's the second image http://www.luisporem.com/projects/pr...nto_glass.html does anyone knows how? thanks |