JavaScript - Simulating An Individual Script Timeout (or Slow Load) With Chrome Devtools
I am trying to work out how to use Google Chrome DevTools to simulate a timeout on a JavaScript file on my site.
I can use the 'Toggle Device Mode' to introduce throttling but that doesn't target a specific script. Is there a way to do this with DevTools? I am using Chrome 38. Similar TutorialsI have a slow loading external JavaScript that displays a calendar widget. When I put it in my sidebar, while the page loads, it cuts off where the calendar should be until the JavaScript for it finishes. How can I make the script load after the page finishes loading? I tried creating a function at the end of the HTML and calling the function in the sidebar, but I think because the function was being called before the script was executed, it didn't work. I appreciate any and all help! I want to use some scripts from http://www.dynamicdrive.com Most of them require pasting script in both the HEAD and BODY of the page. Now, the way my WordPress is set up (Egesto theme), is in individual pages, which I cannot find any way to edit their HEAD or BODY. The only HEAD and BODY sections I see are in the Editor section, where I can edit the overall header.php, but that effects every page, I think. Anyways, does anyone know how I can solve this? Thank you. Hello all, my second post! I finally got the below script working in Firefox and was really pumped about it until I realized it didn't load in Google chrome or Safari. What this script does is its a dual onclick event which makes a hidden div appear and loads an iframe within the now visible div. Here is the code, I would love any input on how to make this work in other browsers. Here is the header code: Code: <SCRIPT type="text/javascript"> <!-- var state = 'none'; function showhide(layer_ref) { if (state == 'block') { state = 'none'; } else { state = 'block'; } if (document.all) { //IS IE 4 or 5 (or 6 beta) eval( "document.all." + layer_ref + ".style.display = state"); } if (document.layers) { //IS NETSCAPE 4 or below document.layers[layer_ref].display = state; } if (document.getElementById &&!document.all) { hza = document.getElementById(layer_ref); hza.style.display = state; } } //--> </script> <SCRIPT type="text/javascript"> function loadIframe(iframeName, url) { if ( window.frames[iframeName] ) { window.frames[iframeName].location = url; return false; } else return true; } </script> Here is the code on the page where a link click shows the hidden div and loads the iframe contained. Code: <p><a href="#" onclick="showhide('div1');return loadIframe('ifrm1', 'http://www.google.com');">show/hide me</a></p> </td></tr> <div id="div1" style="display: none; position: fixed; z-index:4; width: 1010px; height: 500px; left: 5%; top: 15%; background-color: #f0f0f0; border: 1px solid #000; padding: 10px;"><iframe name="ifrm1" id="ifrm1" width="100%" height="90%" scrolling="yes" frameborder="0">Sorry, your browser doesnt support iframes.</iframe><p><a href="#" onclick="showhide('div1')">close</a></div>'; As always, any input is greatly appreciated! Hello everyone! Im new here so any help you can give would be great. I am a Designer, and some time AS3 programer. Teaching my self Javascript for a portfolio website. The Goal: I created a code that randomly creates and Populates Divs in a regular grid, then populates them with an image (using css backgroundImage property) or a print CMY(and Green) color. (eventually will include a shadow box and side scroller) The Problem: The creation and population works just fine, the first time around. if I "Refresh" the page (which i thought destroyed all vars and data) the page loads some times, or freezes. Some times it doesn't load at all! so its very unpredictable, obviously i need this to work the same way every time. Im pretty sure its something simple that i missed, a nuance of javascript or something. So if any one who is more experienced can help I would be super grateful!! here is the page on my website: designchangeseverything.com/beta/divpoptest.html here is the code (i included some of my comments so you can see how i was trying to debug): Code: <SCRIPT LANGUAGE="JavaScript"> var Tborder = .05 var howmanyIMG = 15 var winHeight = Math.floor(window.innerHeight); var winWidth = Math.floor(window.innerWidth); var BoxHeight = Math.floor((winHeight * (1-Tborder)) / 3); var BoxWidth = BoxHeight; var howmanyx = Math.floor(winWidth / BoxWidth) + 1; var howmanyy = 3; var HowMany = howmanyx * howmanyy; var used = new Array(howmanyIMG); var CMYG = ["00AEEF","EC008C","FFF200","41AD49"] function RNDy(numby){ return Math.floor(Math.random()*numby); } function getUniq(){ /* alert("run getuniq");*/ var n; while ( used[ n = RNDy(howmanyIMG) ] ){} used[ n ] = true; return n; } function ColorRND() { if (RNDy(4) ==1) { return true; }else{ return false; } } function PlacePop (HMx,HMy){ var counter = 0; var countc = 0; for(x=0;x<=HMx;x++){ var countr = 0; for(y=0;y<HMy;y++){ var divy = document.createElement("div"); var divyID = 'box' + counter; divy.setAttribute('id', divyID) divy.style.position="absolute"; divy.style.zIndex = counter + 3; divy.style.visibility = 'visible'; divy.style.borderWidth = '1'; divy.style.borderColor = '#000000'; divy.style.pixelLeft= x * BoxWidth + (2 * countc); divy.style.pixelTop= y * BoxHeight + (winHeight * Tborder) + (2 * countr); divy.style.pixelWidth= BoxWidth; divy.style.pixelHeight= BoxHeight; if (ColorRND()){ /*divy.innerHTML = 'color';*/ divy.style.backgroundColor = "#" + CMYG[RNDy(4)]; }else{ /*divy.innerHTML = 'image';*/ divy.style.backgroundImage = "url(resourses/images/portfolio/" + getUniq() + ".png)"; divy.style.backgroundPosition = "center"; /*RNDy(100) + "% " + RNDy(100) + "%";*/ } document.body.appendChild(divy); counter++; countr++; }countc++; } /* alert("ran" + counter + " times");*/ } /* used = null;*/ </script> THANKS FOR ANY HELP YOU CAN GIVE! Hey all, I am reading a book called JavaScript patterns. In it, this method is created: Code: var klass = function(Parent,template){ var Child, F, i; Child = function () { if (Child.uber && Child.uber.hasOwnProperty("__construct")) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty("__construct")) { Child.prototype.__construct.apply(this, arguments); } } Parent = Parent || Object; F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child; for (i in template) { if (template.hasOwnProperty(i)) { Child.prototype[i] = template[i]; } } return Child; } Does anyone have an understanding of why we instantiate a new F() to the Child prototype rather than instantiate the Parent prototype? As you can see above, we assign Parent prototype to F prototype and then instantiate F() object to Child prototype. I'm not sure why it's being done this way. Code: F.prototype = Parent.prototype; Child.prototype = new F(); Thanks for response. Script runs fine in latest stable release of Firefox 3 but breaks in chrome Code: function fixCSS(){ var styles={ 'Yotsuba':'http://static.4chan.org/css/yotsuba.9.css', 'Yotsuba B':'http://static.4chan.org/css/yotsublue.9.css', 'Futaba':'http://static.4chan.org/css/futaba.9.css', 'Burichan':'http://static.4chan.org/css/burichan.9.css' } for(i in document.getElementsByTagName('link')){ for(j in styles){ if(document.getElementsByTagName('link')[i].title==j)document.getElementsByTagName('link')[i].href=styles[j]; } } // if all else fails just delete every link tag and replace with the default linkset // this may be commented out later on if(document.defaultView.getComputedStyle(document.body,'').getPropertyValue('background-color')!='rgb(255, 255, 238)'){ for(i=0;i<document.getElementsByTagName('link').length;i++){ document.getElementsByTagName('link')[0].parentNode.removeChild(document.getElementsByTagName('link')[0]); } var linkHTML='<link rel="shortcut icon" href="http://static.4chan.org/image/favicon.ico"/><link rel="shortcut icon" href="http://static.4chan.org/image/favicon.ico" /><link rel="stylesheet" type="text/css" href="http://static.4chan.org/css/yotsuba.9.css" title="Yotsuba"><link rel="alternate stylesheet" type="text/css" href="http://static.4chan.org/css/yotsublue.9.css" title="Yotsuba B"><link rel="alternate stylesheet" type="text/css" href="http://static.4chan.org/css/futaba.9.css" title="Futaba"><link rel="alternate stylesheet" type="text/css" href="http://static.4chan.org/css/burichan.9.css" title="Burichan">'; document.getElementsByTagName('head').innerHTML=document.getElementsByTagName('head').innerHTML+linkHTML; } var changer='<tr><td>Style [<a href="#" onclick="setActiveStyleSheet(\'Yotsuba\'); return false;">Yotsuba</a> | <a href="#" onclick="setActiveStyleSheet(\'Yotsuba B\'); return false;">Yotsuba B</a> | <a href="#" onclick="setActiveStyleSheet(\'Futaba\'); return false;">Futaba</a> | <a href="#" onclick="setActiveStyleSheet(\'Burichan\'); return false;">Burichan</a>]</td></tr>'; if(document.getElementsByClassName('deletebuttons')[0].parentNode.parentNode.innerHTML.indexOf('setActiveStyleSheet')==-1)document.getElementsByClassName('deletebuttons')[0].parentNode.parentNode.innerHTML+=changer; } function killCotten(){ for(i in document.getElementsByTagName('embed')){ document.getElementsByTagName('embed')[i].parentNode.removeChild(document.getElementsByTagName('embed')[i]); } } killCotten(); fixCSS(); Error message reported by Chrome's "JavaScript Console": Uncaught TypeError: Cannot call method 'removeChild' of undefined killCotten Screenshot of debugger: Hello all, I'm back with more silly newbie questions. I'm building a website that includes 3 javascript codes: 1. Onmouseover image switch for the nav bar. 2. On a specific page, onmouseover display of hidden divs. 3. Particletree's Dynamic Resolution Dependent Layout script (http://particletree.com/features/dyn...ndent-layouts/) All three scripts work fine in firefox, but the 2nd script doesn't work in safari and chrome, and the 3rd one doesn't work in safari, chrome and IE(8). Since the 1st one works fine in all browsers, I'm guessing this isn't a problem with my javascript link or anything like that. The website is: www.sheket.co.il/index4.html The specific page that runs the 2nd code is: www.sheket.co.il/services.html My javascript is: http://www.sheket.co.il/javascript.js And my default stylesheet is: http://www.sheket.co.il/style.css (I apologize for possible jibrish- the website is in Hebrew...) Any help with these two problems would be greatly appreciated! Hi, I was wondering if anyone could help me out with a script I'm trying to create/customize. The idea is to scroll an image by dragging of the mouse (like you have with Google maps for example), instead of the scrollbars. Right now I'm using a script that does the job perfectly fine under IE, but not so much under FireFox, and definitely not under Chrome. Some additional code is probably needed but I have no clue how to write proper JavaScript. Everything I try gives errors and leaves me baffled. Here's a hands-on example of what I mean (works only under IE!): http://home.wanadoo.nl/r.a.dekk/kaart/kaart.html This is the script I'm using now: Quote: <!-- <script type="text/javascript"> document.onmousedown = function(){ var e=arguments[0]||event; var x=document.body.scrollLeft+e.clientX; var y=document.body.scrollTop+e.clientY; document.onmousemove=function(){ scroll(x-e.clientX, y-e.clientY); return false; } document.onmouseup=function(){ document.onmousemove=null; } return false; } </script> //--> Any help will be appreciated. Thanks. I want this script to load after the page load the script is: Code: <script type="text/javascript" src="http://localtimes.info/clock.php?cp3_Hex=0F0200&cp2_Hex=FFFFFF&cp1_Hex=000080&fwdt=118&ham=0&hbg=0&hfg=0&sid=&mon=&wek=&wkf=&sep=&continent=Asia&country=Indonesia&city=Jakarta&widget_number=116"></script> the script in My page is like: 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>My test page</title> </head> <body> <h1>Tony</h1> <h2>Welcome Tony Website</h2> <script type="text/javascript" src="http://localtimes.info/clock.php?cp3_Hex=0F0200&cp2_Hex=FFFFFF&cp1_Hex=000080&fwdt=118&ham=0&hbg=0&hfg=0&sid=&mon=&wek=&wkf=&sep=&continent=Asia&country=Indonesia&city=Jakarta&widget_number=116"></script> <h3>Tony is ... and is....</h3> <h3>He will....</h3> </body> </html> So how can I make this script loads after all elements of My page are loaded and without changing it's position (the script position)? Hello, i'm trying to insert a dynamic js file which contains multiple functions in it (for the example : function x, function y) and it seems that my google chrome doesn't really like it so much is there anyway you know i can bypass it and make it work and both web browsers code examples: // this is where the js file supposed to go <script id="ScriptFile"> </script> //1.js contains function x and function y document.getElementById('ScriptFile').src = "/Mysite/js/1.js" later on i need to preform some actions with function x & y. Couple more issues i need to explain first there are number of js files (1,2,3 .... n ) which all contain the same functions but with different data so i cant register them hard-coded if i type the function x into the "ScriptFile" block, it does work.. its not the function problem. same goes if i include it as source in the "ScriptFile" block (<script id="ScriptFile" src="/Mysite/js/1.js") this only gives me an error while using chrome, works perfectly fine under explorer the error says it cant find function x. thanks alot! Hello, Well I have script that claims that it loads the flash content while it is showing seconds or advertisement. So as I don't know about scripts I have no Idea if it actually do that or not as What I visually see is that it let flash content load once the seconds of disappears. So that's why I want an expert advice on it. And how the seconds of this script works Only if this script actually do what It claims, then I would like to know when does it send alert to load the content (as I would like to put the alert from the start) and how to show it for more or less seconds. Relevant Markup: Live Demo http://files.cryoffalcon.com/MyFootP...%20Loader.html What is the live demo made up of: Code: <div class="colorchooser"> <!--more--> <div class="displaygame_part"> <center> <div id="ads" class="ads"> <h1> ADVERTISEMENT</h1> <center> <script type="text/javascript"><!-- google_ad_client = "ca-pub-0726197409084548"; /* bloghutsgame */ google_ad_slot = "5324930917"; google_ad_width = 336; google_ad_height = 280; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></center> To skip it click <a href="javascript:ShowHide();">here</a> <script type="text/javascript"> window.onload = function() { startCountDown(8, 1000); } function startCountDown(i, p, f) { // store parameters var pause = p; var fn = f; // make reference to div var countDownObj = document.getElementById("countDown"); if (countDownObj == null) { return; } countDownObj.count = function(i) { // write out count countDownObj.innerHTML = i; if (i == 0) { // execute function fn(); // stop return; } setTimeout(function() { // repeat countDownObj.count(i - 1); }, pause ); } // set it going countDownObj.count(i); } </script> <center> <img border="0" height="117" width="201" src="@---put the link of the image of fancy pants(its the loader)---@" /> </center> <div id="countDown" style="display: inline;"> </div> seconds for the game to load... </div> <div id="gamecontent" style="visibility:hidden; display:none"> <div class="gofulldear"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%"> <param name="movie" value="http://games.balloontowerdefense.net/b/balloon_tower_defense_4_expansion.swf"> <param name="quality" value="high"> <param name="allowNetworking" value="internal"> <embed src="http://games.balloontowerdefense.net/b/balloon_tower_defense_4_expansion.swf" width="100%" height="100%" align="center" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allownetworking="internal"></embed> </object> </div> </div> <script type="text/javascript"> function turn_vis_on(id) { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById(id).style.display = 'inline'; obj = document.getElementById(id); obj.style.visibility = "visible"; } } function turn_vis_off(id){ if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById(id).style.display = 'none'; obj = document.getElementById(id); obj.style.visibility = "hidden"; } } function ShowHide() { turn_vis_off("ads"); turn_vis_on("gamecontent"); // alert('4sec!'); } document.getElementById("ads").style.zIndex = 100; timeoutID = setTimeout(ShowHide, 15000); </script> </center></div> </div> Note: It is game so there can be sound or music in it./ For any more information requirement please let me know I will edit it, so to make it as relevant as possible^^. Hi, I was wondering how to add a "loading page please wait" page to my web page, and then run any javascript only after the page loads? My web page contains some fade in/out scripts for pages, and all my pages are basically just divs and in one html file. Just a simple black container (not entire web page) with the words "loading" or something would be fine, then this page would fade out, then my main page would fade in. Thanks. Hey every1. Im a web design student who is trying to make my first webpage for a school project. my problem: I have 2 javascripts i would like to run smooth on my page, but they wont. I have read the info about using the <body onload="dothis()"; "dothat()"> but my problem is the way the 1 javascript is made. i believe so that is. First script: A matrix look-a-like screen for a link. Code: <script type="text/javascript"> // <![CDATA[ var height=9; // height of the effect in rows - must be an odd number var speed=66; // lower is faster var reveal=99; // between 0 and 100 // the higher, the faster the word is 'decoded' var repeat=10; // if '0' the script does not repeat // if set to a number this is the delay until the script repeats var alink="http://www.noma.nu"; // place to link to // set to alink="" if not needed /***************************\ * The Matrix JavaScripted.. * *(c) 2003-6 mf2fm web-design* * http://www.mf2fm.com/rv * * DON'T EDIT BELOW THIS BOX * \***************************/ var timer, table, x, y, columns, ma_txt, ma_cho; reveal/=100; var m_coch=new Array(); var m_copo=new Array(); window.onload=function() This is part im having troubles with. If i do as your toturial tells me i should put Function() down in the body onload command. But it wont work. { if (document.getElementById) { var matrix, tbody, tr, td; matrix=document.getElementById("matrix"); ma_txt=matrix.firstChild.nodeValue; ma_txt=" "+ma_txt+" "; columns=ma_txt.length; while (matrix.childNodes.length) matrix.removeChild(matrix.childNodes[0]); table=document.createElement("table"); table.cellSpacing=0; table.style.margin="auto"; table.style.width="auto"; table.style.border="none"; tbody=document.createElement("tbody"); for (x=0; x<height; x++) { tr=document.createElement("tr"); for (y=0; y<columns; y++) { td=document.createElement("td"); td.className="matrix"; td.appendChild(document.createTextNode(String.fromCharCode(160))); tr.appendChild(td); } tbody.appendChild(tr); } table.appendChild(tbody); matrix.appendChild(table); ma_cho=ma_txt; for (x=0; x<columns; x++) { m_copo[x]=0; ma_cho+=String.fromCharCode(32+Math.floor(Math.random()*94)); } x=0; timer=setInterval("mytricks()", speed); }} function mytricks() { var mtmp, mrow; var z=x; x=0; for (y=0; y<columns; y++) { x=x+(m_copo[y]==100); mrow=m_copo[y]%100; if (mrow && m_copo[y]<100) { if (mrow<height+1) { mtmp=table.rows[mrow-1].cells[y]; mtmp.firstChild.nodeValue=m_coch[y]; mtmp.style.color="#33ff66"; mtmp.style.fontWeight="bold"; } if (mrow>1 && mrow<height+2) { mtmp=table.rows[mrow-2].cells[y]; mtmp.style.fontWeight="normal"; mtmp.style.color="#00ff00"; } if (mrow>2) table.rows[mrow-3].cells[y].style.color="#009900"; if (mrow<Math.floor(height/2)+1) m_copo[y]++; else if (mrow==Math.floor(height/2)+1 && m_coch[y]==ma_txt.charAt(y)) zoomer(y); else if (mrow<height+2) m_copo[y]++; else if (m_copo[y]<100) m_copo[y]=0; } else if (Math.random()>0.9 && m_copo[y]<100) { if (reveal>Math.random() && (z+1)/columns>Math.random()) m_coch[y]=ma_cho.charAt(y); else m_coch[y]=ma_cho.charAt(Math.floor(Math.random()*ma_cho.length)); m_copo[y]++; } } if (x==columns) { if (repeat) { ma_cho=ma_txt; for (x=0; x<columns; x++) { m_copo[x]=0; ma_cho+=String.fromCharCode(32+Math.floor(Math.random()*94)); } } else clearInterval(timer); } } function zoomer(ycol) { var mtmp, mtem, ytmp; if (m_copo[ycol]==Math.floor(height/2)+1) { for (ytmp=0; ytmp<height; ytmp++) { mtmp=table.rows[ytmp].cells[ycol]; mtmp.firstChild.nodeValue=m_coch[ycol]; mtmp.style.color="#33ff66"; mtmp.style.fontWeight="bold"; if (alink) { mtmp.style.cursor="pointer"; mtmp.onclick=function() {window.location.href=alink}; } } mtmp=ma_cho.indexOf(ma_txt.charAt(ycol)); m_copo[ycol]+=199; setTimeout("zoomer("+ycol+")", speed); } else if (m_copo[ycol]>200) { mtmp=table.rows[m_copo[ycol]-201].cells[ycol]; mtem=table.rows[200+height-m_copo[ycol]].cells[ycol]; m_copo[ycol]-=1; mtmp.style.fontWeight="normal"; mtem.style.fontWeight="normal"; setTimeout("zoomer("+ycol+")", speed); } else if (m_copo[ycol]==200) m_copo[ycol]=100+Math.floor(height/2); if (m_copo[ycol]>100 && m_copo[ycol]<200) { mtmp=table.rows[m_copo[ycol]-101].cells[ycol]; mtmp.firstChild.nodeValue=String.fromCharCode(160); mtem=table.rows[100+height-m_copo[ycol]].cells[ycol]; mtem.firstChild.nodeValue=String.fromCharCode(160); m_copo[ycol]-=1; setTimeout("zoomer("+ycol+")", speed); } } // ]]> </script> Second script: a simple digital clock. Code: <script type="text/javascript"> function showClock() { // create a new Date() object var currentTime=new Date(); var hours=currentTime.getHours(); var minutes=currentTime.getMinutes(); var seconds=currentTime.getSeconds(); var area=currentTime.getTimezoneOffset(); area=area/60; var clock=hours; // add a zero in front of numbers<10 if (minutes<10){ minutes="0" + minutes; } if (seconds<10){ seconds="0" + seconds; } document.getElementById('clock').innerHTML="<table><tr><td width=80 align=center>"+clock+":"+minutes+":"+seconds+"</td>" +"" +""; t=setTimeout('showClock()',500); // setTimeout calls showClock() function every 500 miliseconds, that means 0.5 seconds } </script> <body onload="showclock()"> this is where the clock load. It works fine. how do i get the other script to load with this. I can get them both to run but not at same time. Any1 outthere who have a solution. I believe it has something to do with Function() part in the matrix code. can i change that do another command? Hey guys. I host a private website that I use to broadcast my DJ mixes live to my friends. I'm currently using a PHP script on the home-page to say whether I'm broadcasting currently, or if I'm offline. The script works great, but it really slows down the page loading time. Is there a way to have the page load, and then just have the "Status:" say "Checking..." until the PHP script can determine if I'm streaming or offline? This is my PHP code: PHP Code: <?php if (url_validate($link)) { echo "LIVE"; } else { echo "OFFLINE"; } ?> Thank you! Any help would be greatly appreciated... I'm trying to get cross-browser column support working using the "css3-multi-column.js" script included in the following tutorial: http://www.cvwdesign.com/txp/article/360 The javascript works, making columns when the site is loaded in Firefox but I keep getting "access denied" errors for the ""css3-multi-column.js" script in Internet Explorer 8, resulting in no columns. I tested the tutorial's example in IE 8 (worked fine), then referred to the tutorial's example time and again checking for discrepancies but I can't seem to figure out where I'm going wrong. Here's an example on my site where columns are to appear: http://www.burnmyeye.org/site/about-us Thanks once again. I am trying to run this script when the page loads I have tried different methods but still no luck I would appreciate it if somebody help me out [CODE]<a href="http://s230999743.mysite.com/768K.WMA" onclick="var win=window.open('','mywindow','height=523, width=640');win.document.write('\x3Chtml\x3E\x3Chead\x3E\x3Ctitle\x3EVideo Window\x3C/title\x3E\x3Cstyle\x3Ehtml,body {margin:0;padding:0;}\x3C/style\x3E\x3C/head\x3E\x3Cbody\x3E\x3Cembed src=\'http://s230999743.mysite.com/768K.WMA\' width=\'640\' height=\'523\' autostart=\'1\' showcontrols=\'1\' type=\'application/x-mplayer2\' pluginspage=\'http://www.microsoft.com/windows/windowsmedia/download/\'\x3E \x3C/embed\x3E\x3C/body\x3E\x3C/html\x3E');return false;">Enter link text here.</a>[CODE] I am trying to make the following fill the value box when the page loads as opposed to pressing the button. I cant seem to do it. Any ideas?? PHP Code: <script> var keylist="abcdefghijklmnopqrstuvwxyz123456789" var temp='' function generatepass(plength){ temp='' for (i=0;i<plength;i++) temp+=keylist.charAt(Math.floor(Math.random()*keylist.length)) return temp } function populateform(enterlength){ document.pgenerate.output.value=generatepass(enterlength) } </script> <form name="pgenerate"> <input type="text" size=18 name="output"> <input type="button" value="Generate Password" onClick="populateform(this.form.thelength.value)"><br /> <b>Password Length:</b> <input type="text" name="thelength" size=3 value="7"> </form> How do I make my Script load faster? Is there Code that will make my Script load faster, (so that it won't take so long to view) If so, can someone show me how to incorporate it into my Example Script? With appreciation Hi, Im trying to load a remote script but only if a statement is true.. Code: <script type="text/javascript"> var width=screen.width; if (width>1023); { // load remote script } </script> How would I go about this? And will it work if the script in php? Thank youu! EDIT: I realise its probably not the best practice but at the moment im having to use Code: <script language="javascript"> window.location.href = "index2.php?width=" + screen.width; </script> and on index2.php Code: <?php $res=$_GET['width']; if ($res > 1024) { include("header.php"); } ?> |