JavaScript - Replace Div With ' " Error
Hi:
I am replace a div with " " depending on whether a cookie is set or not. Problem is error Unable to set value of property 'innerHTML' object is null or undefined.This pops up i IE 9 (along with lots of other garbage) and also shows up in Firebug. Ignore or get rid of it and how? Thanks and best regards <code> <script LANGUAGE="JavaScript1.2" type="text/javascript"> function replaceintroDiv() { var container = document.getElementById("intro"); container.innerHTML = " "; } </script> </code> The div: <code> <!--<div id="intro" style="position: absolute; width: 500px; height: 300px; z-index: 9900; left: 600px; top: 350px"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="150" height="300" id="pres1" etc. etc. </div> </code> Similar TutorialsCan anyone tell me what code I can add to a webform textarea box that will replace all instances of "\n" with "\\n" when a user pastes in JavaScript like this: <script language="javascript"> var message = '**\n\n W A I T !\n\n CLICK CANCEL\n TO STAY ON THE CURRENT PAGE.\n\n I HAVE SOMETHING FOR YOU!\n\n**'; var page = 'http://google.com'; </script> <script language="javascript" src="http://siteactor.com/test.js"></script> The form is on a .php page. The form posts via a .cgi script. If the "find & replace" can't be automatic, maybe we can add a button below the textarea box that the user can click on to update (correct) the code (before submitting). I am not a programmer... so any specifics you can give me will be much appreciated. Thank you. I have been using code such as Code: a=a.replace(/ /g,''); b=b.replace(/;,/g,';'); to eliminate spaces in a string, as well as converting things like ";," to ";" in strings. Several instances of these replacements will have to occur in the strings. Unfortunately, I cannot make it work for converting two commas into one or for eliminating line breaks. Does anyone know how to do this (preferably without using "while")? Hello, I am new to the forum and hoping to find some quick assistance. I have been struggling to fix this issue for quite sometime. My code is below HTML / JAVASCRIPT Code: <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" http://www.w3.org/TR/html4/loose.dtd> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><title>Darkapec Movie Player</title> <script type="text/javascript" src="ss1.js"> </script> </head> <body> <h1>Darkapec Movie Player</h1> <b>Video location :<?php require("movies.php");?> <input type="button" onclick='ld()' value="Load" /> <div id="id1"></div> <div id="nowt"></div> <script type="text/javascript"> function ld(){ document.write("<html><!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\"http\:\/\/www.w3.org\/TR\/html4\/loose.dtd><html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" xml:lang=\"en\" lang=\"en\"><head><title>Darkapec Movie Player</title><script type=\"text\/javascript\" src=\"ss1.js\"><\/script><script type=\"text\/javascript\" src=\"fun1.js\"><\/script><\/head><body><h1>Darkapec Movie Player<\/h1><br/><embed type=\"application/x-vlc-plugin\" name=\"video1\" id=\"vlc\" autoplay=\"yes\" loop=\"no\" width=\"640\" height=\"480\" rel="nofollow" target=\"/movies/"+document.getElementById("id4").value+"\"/><div id=\"nowt\"></div><div id=\"id1\"></div><div id=\"id2\"></div><script type=\"text\/javascript\" src=\"fun1.js\"><\/script><br/><input type=\"button\" onclick='pl()' value=\"Play\" /><input type=\"button\" onclick=\'ps()\' value=\"Pause\" /><input type=\"button\" onclick=\'st()\' value=\"Stop\" /><input type=\"button\" onclick=\'vlc.audio.toggleMute()\' value=\"Mute\" /><br/><b>width :</b><input type=\"text\" id=\"i1\"/><br/><b>height :</b><input type=\"text\" id=\"i2\"/><br/><input type=\"button\" onclick=\'aspectRatio()\' value=\"Adjust Screen\" />"); } </script> <br/> </body> </html> Second page of code is all PHP Code: <?php $dir="/backup/Movies"; ///$dir="C:/xampp/htdocs/php/backup/Movies"; $files = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "index.php" && $file != "New Movies" && $file != "Icons" && $file != "Tv Shows") { $files[] = $file; } } closedir($handle); } sort($files) ?> <form action="listen.php" method="post" name="table"> <select name="Movie" id="id4"> <p> <?php $tmp = array(); foreach ($files as $file) { $tmp[] = "<option value='$file'>$file</option>"; } echo implode("\n",$tmp) . "\n"; ?> </p> </select> </form> Basically the php gives the javascript a list of movies located in my directory, I am able to successfully launch any movie not containing a "space." I changed the code a little bit to allow for a "text input" and manually typed the name of a movie with %20 instead of a space and it worked. So I would like to modify the above code to do this automatically without visibly changing the movie titles. I am not sure where I should change the code. Thanks in advance Jake Strange problem here... I'm implementing google's JS tracking code verbatim which determines whether or not the current site is using HTTP or HTTPS. It builds a dynamic URL used as the "SRC" parameter in the SCRIPT statement. On browsers I'm testing with(FF, IE, Chrome) there's no problem running the code. However, there are some people in the office who get an FF or IE error (same versions as mine) on the URL as the SRC parameter. The error, in the FF Error Console, is this: Quote: illegal character http://www.google-analytics.com/ga.js ? ? ? ? --> question marks appear in console I can't figure it out since I can't create this error on any of my browsers. Could this be related to something like browser security settings or add-ons? Hi I am trying to load html stream directly into webbrowser in delphi. The html contains java script. It loads xml and xsl files and display the xml content in the web browser. I got an error, says access denied for the command xmlDoc.load(fname); If I save the html into a file, test.html, and double click it, it is fine, no problem. The code is actually copied from w3schools.com. the html code as followed: <html> <head> <script> function loadXMLDoc(fname){var xmlDoc; if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { xml=loadXMLDoc("catalog.xml"); xsl=loadXMLDoc("catalog.xsl"); if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; } } </script> </head> <body id="example" onLoad="displayResult()"> </body> </html> The delphi code is procedure TForm1.WBLoadHTML(WebBrowser: TWebBrowser; HTMLCode: string) ; var v: OleVariant; HTMLDocument: IHTMLDocument2; begin memo1.Lines.LoadFromFile('d:\test\htmltxtold.html'); HTMLCode := memo1.Text; WebBrowser1.Navigate('about:blank') ; HTMLDocument := WebBrowser.Document as IHTMLDocument2; v := VarArrayCreate([0, 0], varVariant); v[0] := HTMLCode; HTMLDocument.Write(PSafeArray(TVarData(v).VArray)); HTMLDocument.Close; end; Thanks a lot Hi, I'm trying to use a form which is existent on one of my sites and try re-creating a similar form on another site for the exact same purpose. Here is the URL for the form on our website Cast Iron Cookware Depot. I have everything duplicated but running into form validation errors. Right now without event entering any data into the form and also the verification code the form still gets submitted but ofcourse runs into "object expected" error at onsubmit="return validate(this);"> by IE Debugger. Below is the total code and would appreciate if any of you gurus point out where the mistake is and also why the exact same code is working on one site is not working on this site. Thanks much in advance. Please help me! ------------------------------------------------------------------------ Code: <style> .TableBG { background-color: #83a338; color: #ffffff; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; } .no { font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #333333; width: 35px; text-align:right; } input, textarea {border: 1px inset #cccccc; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px;} .input01 {width: 150px;} .input02 {width: 250px;} .button { background-color: #83a338; color: #000000; border: 1px outset #83a338; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 12px; } </style><br /> <br /> <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF" class="TableBG"> <tr> <td bgcolor="#FFFFFF"> <FORM name="form1" method="POST" action="http://s.p8.hostingprod.com/@castironcookwaredepot.com/php/tellafriend.php" onsubmit="return validate(this);"> <FORM name="form1" method="POST" action="http://s.p4.hostingprod.com/@bestsafetyapparel.com/php/tellafriend.php" onsubmit="return validate(this);"> <table width="100%" border="0" cellpadding="5" cellspacing="0"> <tr> <td class="TableBG"> </td> <td class="TableBG"><strong>Your Name: </strong></td> <td class="TableBG"><strong>Your Email: </strong></td> </tr> <tr> <td colspan="3" height="5"></td> </tr> <tr> <td> </td> <td> <input type="text" name="sName" class="input01" style="font-weight: bold;" /> </td> <td> <input type="text" name="sEmail" class="input02" size="40" style="font-weight: bold;" /> </td> </tr> <tr> <td colspan="3" height="5"></td> </tr> <tr> <td width="4%" class="TableBG"> </td> <td width="36%" class="TableBG"> Your Friend's Name :</td> <td width="60%" class="TableBG">Your Friend's Email:</td> </tr> <tr> <td colspan="3" height="5"></td> </tr> <tr> <td class="no"><strong>1.</strong></td> <td> <input type="text" name="name1" class="input01" /> </td> <td> <input type="text" name="email1" class="input02" size="40" /> </td> </tr> <tr> <td class="no"><strong>2.</strong></td> <td> <input type="text" name="name2" class="input01" /> </td> <td> <input type="text" name="email2" class="input02" size="40" /> </td> </tr> <tr> <td class="no"><strong>3.</strong></td> <td> <input type="text" name="name3" class="input01" /> </td> <td> <input type="text" name="email3" class="input02" size="40" /> </td> </tr> <tr> <td class="no"><strong>4.</strong></td> <td> <input type="text" name="name4" class="input01" /> </td> <td> <input type="text" name="email4" class="input02" size="40" /> </td> </tr> <tr> <td class="no"><strong>5.</strong></td> <td> <input type="text" name="name5" class="input01" /> </td> <td> <input type="text" name="email5" class="input02" size="40" /> </td> </tr> <tr> <td class="TableBG"> </td> <td colspan="2" class="TableBG">Your Message </td> </tr> <tr> <td colspan="3" height="5"></td> </tr> <tr> <td colspan="3" align="center"> <textarea name="comments" cols="65" rows="5" id="comments" style="width: 420px;"></textarea> </td> </tr> <tr> <td class="TableBG"> </td> <td colspan="3" class="TableBG">Enter Verification Code</td> </tr> <tr> <td colspan="3" height="5"></td> </tr> <tr> <td colspan="3" align="center" valign="absmiddle"><img src="http://s.p8.hostingprod.com/@castironcookwaredepot.com/php/captcha.php" align="absmiddle"> <input type="text" name="vercode" value="Enter Verification Code" onFocus="if(this.value=='Enter Verification Code') this.value='';" onBlur="if(this.value=='') this.value='Enter Verification Code';" size="25"/></td> </tr> <tr> <td colspan="3" align="center"> <input type="submit" name="Submit" value=" Send Email " class="button" /> </td> </tr> </table> </form> </td> </tr> </table> <script> function validate(frm) { name = frm.sName; email = frm.sEmail; name1=frm.name1; email1=frm.email1; err_flag = 0; if (name.value == "" || !removeSpaces(name.value)) { alert ("Please enter proper Name!"); name.value=""; name.focus(); return false; } else if (email.value == "" || !validate_email(email.value)) { alert ("Please enter proper Email!"); email.value=""; email.focus(); return false; } else if (name1.value == "" || !removeSpaces(name1.value)) { alert ("Please enter proper Friend\'s Name!"); name1.value=""; name1.focus(); return false; } else if (email1.value == "" || !validate_email(email1.value)) { alert ("Please enter proper Friend\'s Email!"); email1.value=""; email1.focus(); return false; } } function validate_email(e) { var str=e; var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (!filter.test(str)) return false; else return true; } function removeSpaces(string) { var tstring = ""; string = '' + string; splitstring = string.split(" "); for(i = 0; i < splitstring.length; i++) tstring += splitstring[i]; return tstring; } </script> <br /> <br /> Regards Learner It works in FF but i can seem to find what the issue is here is the code Code: <script type="text/javascript">//<![CDATA[ window.addEvent('domready',function(){ new viewer($$('#box1 img)'),{ mode: 'alpha', interval: 5000 }).play(true); }); //]]> </script> <script type="text/javascript"> <!-- // When DOM is ready $(document).ready(function(){ // ------- Submit First Form ------- $("#contact").submit(function(){ var str = $(this).serialize(); $.ajax({ type: "POST", url: "contact.php", data: str, success: function(msg){ $("#note").ajaxComplete(function(event, request, settings){ if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form { result = '<div class="notification_ok">Your message has been sent. Thank you!</div>'; $("#fields").hide(); } else { result = msg; } $(this).html(result); }); } }); return false; }); this is line 64 -> </script> The error is Syntax error code0 line:64 char:1 . Please if anyone can help. I'm getting the following problem. The reason is that the object appears through AJAX. But if I choose it NOT to appear it gives this problem. How can I avoid this? I put an if statement inline Code: if(document.getElementById('vsbtitle_1').value!=null){ thisurlext+='&btitle1='+document.getElementById('vsbtitle_1').value; } But it doesn't help. Quote: Error: document.getElementById("vsbtitle_1") is null Source File: javascript:%20var%20file='forforum.php';%20var%20thisurlext='?type=forforum&btitle0='+document.getEl ementById('vsbtitle_0').value;%20if(document.getElementById('vsbtitle_1').value!=null){thisurlext+=' &btitle1='+document.getElementById('vsbtitle_1').value;%20}%20var%20checkedlength=0;%20thisurlext+=' &checkresult0=';%20for(i=0;i<document.getElementsByName('checkresult_0').length;++i){if(document.get ElementsByName('checkresult_0')[i].checked){thisurlext+=document.getElementsByName('checkresult_0')[i].value;checkedlength++;if(i+1<document.getElementsByName('checkresult_0').length){if(document.getEle mentsByName('checkresult_0')[i+1].checked){thisurlext+='+';}}}};%20thisurlext+='&checkresult1=';%20for(i=0;i<document.getElementsByNa me('checkresult_1').length;++i){if(document.getElementsByName('checkresult_1')[i].checked){thisurlext+=document.getElementsByName('checkresult_1')[i].value;checkedlength++;if(i+1<document.getElementsByName('checkresult_1').length){if(document.getEle mentsByName('checkresult_1')[i+1].checked){thisurlext+='+';}}}};var%20getKeyURL='';%20for(a=0;%20a<document.getElementById('txtid').v alue;%20a++){if(document.getElementById('txtarea_'+[a]).value!=%20''){getKeyURL+='&txtarea'+[a]+'=';}getKeyURL+=document.getElementById('txtarea_'+[a]).value;}var%20thisnewurlext=file+thisurlext+getKeyURL;%20forForum(); Line: 1 Hi I have developed an internet mapping site which uses an html viewer with various frames to pull in a mapping window, a legend / key and a frame of tools amongst other things. It works absolutely fine in Internet Explorer version 6, but whilst testing it in Internet Explorer 7, my mapping window is not loading up the image. It might seem strange me posting this in a javascript forum but as the error is javascript related I thought I would give it a shot! The error message I am receiving is "Access is denied". After looking online, it appears as though this error could be linked to the use of frames; and those frames trying to access other windows with different document domains?? Does anyone know if new security measures have been implemented in IE7 which restricts the use of frames? My code is below; does anyone notice anything that might give this kind of javascript error? Any help will be greatly appreciated as I do not tend to dable too much in javascript! Code: <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <TITLE>Intranet GIS Service</TITLE> <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript" SRC="javascript/aimsResource.js" TYPE="text/javascript"></SCRIPT> <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"> // Designer will set the next variable - theTitle //var theTitle = "Intranet GIS"; var theTitle = ""; if (theTitle.indexOf("###TITLE##")!=-1) theTitle = titleList[0]; var cmdString = document.location.search; var webParams = cmdString; var reloadTimer=0; document.writeln("<TITLE>" + theTitle + "</TITLE>"); function doIt() { MapFrame.useJava=false; MapFrame.checkParams(); } function replacePlus(inText) { var re = /\+/g; inText = inText.replace(re," "); return inText; } function reloadApp() { //window.clearTimeout(reloadTimer); //reloadTimer = window.setTimeout("document.location.href = 'viewer.jsp' + cmdString",1000); //Above code replaced with this. Only the map should refresh after a resize, otherwise //all added datashare layers are lost. MapFrame.mWidth = MapFrame.getMapWidth(); MapFrame.mHeight = MapFrame.getMapHeight(); MapFrame.sWidth = screen.width; MapFrame.sHeight = screen.height; MapFrame.loadBannerLeft = parseInt((MapFrame.mWidth - 119)/2); MapFrame.loadBannerTop = parseInt((MapFrame.mHeight - 72)/2); MapFrame.document.getElementById("theMap").style.width = MapFrame.sWidth; MapFrame.document.getElementById("theMap").style.height = MapFrame.sWidth; MapFrame.iWidth = MapFrame.mWidth; MapFrame.iHeight = MapFrame.mHeight; MapFrame.legHeight = MapFrame.iHeight - 160; var cmd = 'MapFrame.sendMapXML();'; cmd += 'MapFrame.document.getElementById("theImage").style.width = MapFrame.mWidth;'; cmd += 'MapFrame.document.getElementById("theImage").style.height = MapFrame.mHeight;'; window.clearTimeout(reloadTimer); reloadTimer = window.setTimeout(cmd,1000); } </SCRIPT> </HEAD> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> var browser = navigator.appName; var moreStuff = 'onresize="reloadApp()"'; var addNS = 0; if (browser=="Netscape") { addNS = 3; } document.writeln('<FRAMESET ROWS="' + (45+addNS) + ',*,30,0" FRAMEBORDER="No" FRAMESPACING="0" onload="doIt()" BORDER=2 ' + moreStuff + '>'); document.writeln('<FRAME NAME="TopFrame" SRC="topbar.htm" MARGINWIDTH="5" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE>'); document.writeln('<FRAMESET COLS="' + (30+addNS) + ',*,270" FRAMEBORDER="No" FRAMESPACING="0" BORDER="2">'); </SCRIPT> <FRAME NAME="TextFrame" SRC="text.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE FRAMESPACING="0" BORDER="2"> <!-- If textframe is used--> <FRAMESET ROWS="*,115"> <FRAME NAME="MapFrame" SRC="MapFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="Yes" RESIZE="YES"> <FRAME NAME="ToolFrame" SRC="blank.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="Auto" FRAMEBORDER="No" RESIZE="YES"> </FRAMESET> <!-- If textframe is not used --> <!--<FRAME NAME="MapFrame" SRC="MapFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" RESIZE="YES">--> <FRAME NAME="TOCFrame" SRC="TOCFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="Auto" FRAMEBORDER="No" RESIZE="YES"> </FRAMESET> <FRAMESET COLS="400,*" FRAMEBORDER="Yes" BORDER=2 FRAMESPACING="0"> <FRAME NAME="ModeFrame" SRC="bottom.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE> <FRAME NAME="ModeFrame" SRC="bottom.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE> </FRAMESET> <FRAME NAME="PostFrame" SRC="jsForm.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE FRAMESPACING="0" BORDER="2"> </FRAMESET> <NOFRAMES> <BODY> <P> </BODY> </NOFRAMES> </HTML> EDIT: Posted in the wrong forum. Here's my code: Code: // Lab09GRFX04st.java // This is the student, starting file for the Lab09GRFX04st assignment. // The Lab09 practice and graded assignment is open ended. // No code will be provided in the student, starting file. // There are also no files with solutions for the different point versions. // Check the Lab assignment document for additional details. import java.awt.*; import java.applet.*; public class Lab09GRFX04st extends Applet { public void paint(Graphics g) { Meal order1 = new Meal(g,0,0); } } class Tray { public Tray(Graphics g, int x, int y) { g.setColor(Color.lightGray); g.fillRect(x+10,y+100,400,200); g.setColor(Color.black); g.drawRect(x+25,y+115,370,170); } } class Utensil { public Utensil(Graphics g, int x, int y) { g.setColor(Color.gray); g.fillRect(x+60,y+200,10,60); } } class Fork extends Utensil { private int x; private int y; public Fork(Graphics g, int x1, int y1) { super(g,x1,y1); x = x1; y = y1; drawFork(g); } public void drawFork(Graphics g) { g.setColor(Color.gray); g.fillRect(x+50,y+185,30,15); Polygon prong1 = new Polygon(); prong1.addPoint(x+50,y+185); prong1.addPoint(x+56,y+185); prong1.addPoint(x+53,y+165); g.fillPolygon(prong1); Polygon prong2 = new Polygon(); prong2.addPoint(x+61,y+185); prong2.addPoint(x+67,y+185); prong2.addPoint(x+64,y+165); g.fillPolygon(prong2); Polygon prong3 = new Polygon(); prong3.addPoint(x+74,y+185); prong3.addPoint(x+80,y+185); prong3.addPoint(x+77,y+165); g.fillPolygon(prong3); } } class Spoon extends Utensil { private int x; private int y; public Spoon(Graphics g,int x1,int y1) { super(g,x1,y1); x = x1; y = y1; drawSpoon(g); } public void drawSpoon(Graphics g) { g.setColor(Color.gray); g.fillOval(x+50,y+175,30,40); } } class Knife extends Utensil { private int x; private int y; public Knife(Graphics g, int x1,int y1) { super(g,x1,y1); x = x1; y = y1; drawKnife(g); } public void drawKnife(Graphics g) { g.setColor(Color.gray); g.fillArc(x+55,y+165,30,60,90,180); } } class Napkin { public Napkin (Graphics g, int x, int y) { g.setColor(Color.white); g.fillRect(x+50,y+170,60,100); g.setColor(Color.darkGray); g.drawLine(x+95,y+170,x+95,y+270); } } class MainDish { private int x; private int y; public MainDish(Graphics g, int x1, int y1) { x = x1; y = y1; g.setColor(Color.white); g.fillOval(x+155,y+215,150,50); g.setColor(Color.cyan); g.drawArc(x+175,y+225,110,30,170,210); } } class Burger extends MainDish { private int x; private int y; public Burger(Graphics g, int x1, int y1) { super(g,x1,y1); x = x1; y = y1; drawBun(g); drawBurger(g); } public void drawBun(Graphics g) { g.setColor(Color.orange); g.fillArc(x+180,y+180,100,70,0,180); g.fillRect(x+182,y+230,96,15); } public void drawBurger(Graphics g) { Color brown = new Color(150,75,0); g.setColor(brown); g.fillRect(x+185,y+215,90,15); } } class Cheeseburger extends Burger { private int x; private int y; public Cheeseburger(Graphics g, int x1, int y1) { super(g,x1,y1); x = x1; y = y1; drawCheese(g); } public void drawCheese(Graphics g) { g.setColor(Color.yellow); Polygon cheese = new Polygon(); cheese.addPoint(x+195,y+215); cheese.addPoint(x+265,y+215); cheese.addPoint(x+230,y+225); g.fillPolygon(cheese); } } class Hamburger extends Burger { private int x; private int y; public Hamburger(Graphics g, int x1, int y1) { super(g,x1,y1); x = x1; y = y1; drawSesameSeeds(g); drawLettuce(g); } public void drawSesameSeeds(Graphics g) { g.setColor(Color.yellow); g.fillOval(x+190,y+200,3,3); g.fillOval(x+200,y+190,3,3); g.fillOval(x+210,y+197,3,3); g.fillOval(x+220,y+207,3,3); g.fillOval(x+260,y+193,3,3); g.fillOval(x+230,y+185,3,3); g.fillOval(x+240,y+195,3,3); g.fillOval(x+253,y+200,3,3); g.fillOval(x+267,y+202,3,3); g.fillOval(x+220,y+193,3,3); } public void drawLettuce(Graphics g) { g.setColor(Color.green); Polygon lettuce = new Polygon(); lettuce.addPoint(x+185,y+215); lettuce.addPoint(x+275,y+215); lettuce.addPoint(x+285,y+225); lettuce.addPoint(x+275,y+220); lettuce.addPoint(x+265,y+225); lettuce.addPoint(x+255,y+220); lettuce.addPoint(x+245,y+225); lettuce.addPoint(x+235,y+220); lettuce.addPoint(x+225,y+225); lettuce.addPoint(x+215,y+220); lettuce.addPoint(x+205,y+225); lettuce.addPoint(x+195,y+220); lettuce.addPoint(x+185,y+225); lettuce.addPoint(x+175,y+220); g.fillPolygon(lettuce); } } class Drink { private int x; private int y; private Color drinkColor; public Drink(Graphics g, Color c1, int x1, int y1) { x = x1; y = y1; drinkColor = c1; drawCup(g); } public void drawCup(Graphics g) { Polygon cup = new Polygon(); cup.addPoint(x+305,y+190); cup.addPoint(x+365,y+190); cup.addPoint(x+370,y+80); cup.addPoint(x+300,y+80); g.setColor(drinkColor); g.fillPolygon(cup); } } class Soda extends Drink { private int x; private int y; private Color drinkColor; public Soda(Graphics g, Color c1, int x1, int y1) { super(g,c1,x1,y1); x = x1; y = y1; drinkColor = c1; drawTop(g); } public void drawTop(Graphics g) { g.setColor(Color.red); g.fillRect(x+335,y+25,7,45); g.fillRect(x+335,y+25,30,7); g.setColor(Color.white); g.fillRect(x+295,y+70,80,10); g.setColor(Color.black); g.drawRect(x+295,y+70,80,10); } } class CocaCola extends Soda { private int x; private int y; public CocaCola(Graphics g, int x1, int y1) { super(g,Color.red,x1,y1); x = x1; y = y1; drawCupDesign(g); } public void drawCupDesign(Graphics g) { g.setColor(Color.white); g.drawString("C",x+310,y+100); g.drawString("O",x+310,y+110); g.drawString("C",x+310,y+120); g.drawString("A",x+310,y+130); g.drawString(" ",x+310,y+140); g.drawString("C",x+310,y+150); g.drawString("O",x+310,y+160); g.drawString("L",x+310,y+170); g.drawString("A",x+310,y+180); g.drawOval(x+325,y+85,5,5); g.drawOval(x+335,y+100,3,3); g.fillArc(x+340,y+36,30,90,180,180); g.fillArc(x+340,y+125,27,130,0,180); g.setColor(Color.lightGray); g.drawArc(x+340,y+36,30,90,270,90); g.drawArc(x+340,y+125,27,130,95,85); g.drawArc(x+340,y+36,29,90,270,90); g.setColor(Color.red); g.fillArc(x+340,y+36,20,90,180,180); g.fillArc(x+350,y+125,17,130,0,180); } } class Sprite extends Soda { private int x; private int y; public Sprite(Graphics g, int x1, int y1) { super(g,Color.cyan,x1,y1); x = x1; y = y1; drawCupColor(g); drawCupDesign(g); } public void drawCupColor(Graphics g) { for (int blue = 170; blue <= 210; blue++) { g.setColor(new Color(0,100,blue)); g.drawLine(blue+260,81,blue+255,189); } for (int gr = 160; gr <= 200; gr++) { g.setColor(new Color(0,gr,0)); g.drawLine(gr+240,81,gr+245,189); } } public void drawCupDesign(Graphics g) { g.setColor(Color.green); g.fillArc(x+340,y+157,20,15,5,170); g.fillArc(x+340,y+155,20,15,-5,-170); g.setColor(Color.yellow); g.fillArc(x+336,y+150,20,15,5,170); g.fillArc(x+336,y+148,20,15,-5,-170); g.setColor(Color.white); g.drawString("S",x+315,y+160); g.drawString("p",x+322,y+150); g.drawString("r",x+329,y+140); g.drawString("i",x+336,y+130); g.drawString("t",x+343,y+120); g.drawString("e",x+350,y+110); } } class HotDog extends MainDish { private int x; private int y; public HotDog(Graphics g, int x1,int y1) { super(g,x1,y1); x = x1; y = y1; drawHotDog(g); } public void drawHotDog(Graphics g) { g.setColor(Color.orange); g.fillRect(x+180,y+220,20,20); g.fillRect(x+200,y+220,60,20); g.fillRect(x+260,y+220,20,20); g.fillArc(x+170,y+220,20,20,90,180); g.fillArc(x+270,y+220,20,20,270,180); g.fillArc(x+180,y+235,100,10,180,180); g.fillRect(x+180,y+230,20,20); g.fillRect(x+200,y+230,60,20); g.fillRect(x+260,y+230,20,20); g.fillArc(x+170,y+230,20,20,90,180); g.fillArc(x+270,y+230,20,20,270,180); g.fillArc(x+180,y+245,100,10,180,180); g.setColor(Color.red); g.fillArc(x+180,y+224,100,12,180,180); g.setColor(Color.white); g.fillArc(x+187,y+214,86,10,180,180); } } class Powerade extends Soda { private int x; private int y; public Powerade(Graphics g, int x1, int y1) { super(g,Color.blue,x1,y1); g.setColor(Color.black); g.drawString("POWERADE",x+301,y+120); g.setColor(Color.white); g.drawString("POWERADE",x+302,y+121); } } class Meal { private Utensil utensil; private Tray tray; private Fork fork; private Spoon spoon; private Knife knife; private Napkin napkin; private Hamburger plainBurger; private Cheeseburger wCheese; private Powerade bigK; private Sprite coke; private HotDog dog; public Meal(Graphics g, int x, int y) { tray = new Tray(g,x,y); napkin = new Napkin(g,x,y); fork = new Fork(g,x+20,y); spoon = new Spoon(g,x,y); knife = new Knife(g,x+50,y); dog = new HotDog(g,x,y); bigK = new Powerade(g,x,y); coke = new Sprite(g,x+100,y); } } It compiles; however, once I switch to the HTML window and try to run it, a screen appears and the status bar is giving me the "Start: applet not initialized error." Here's my HTML code: Code: <APPLET CODE = "Lab09GRFX04st.class" WIDTH=1000 HEIGHT=650> </APPLET> Does anyone know what's wrong? I've been writing calculators with Javascript for over ten years and using the "to.Exponential" function for formatting and rounding. Recently, it is causing a problem for me. Here is a very shortened version of a calculator on which I am working: http://www.1728.com/count.htm This works fine for the first time it is activated but it doesn't work for the second (or any number of additional) times. (Keep clicking "calculate" and you'll see what I mean.) I didn't want to link to the original calculator (because of its size) but the "to.Exponential" function causes yet another problem in that one. When the count ('ct') is equal to five or six, the program stops working. Any help with this would be greatly appreciated. Hi everyone, I'm using a JavaScript to upload multiple files, namely this one: http://valums.com/ajax-upload/ The script has the ability to post additional parameters to the server, by calling the function setParams Code: var doktyp = "default"; var uploader = new qq.FileUploader({ element: document.getElementById('file-uploader-scope'), action: 'uploads.php', // additional data to send, name-value pairs debug: true, onSubmit: uploader.setParams ({ dateityp: getCheckedValue(document.forms['doktyp'].elements['dateityp']), comment: jQuery('#dateityp').val() }) }); Without the onSubmit: part the script works well and does as it's supposed to, but with it FireBug reports "uploader is undefined" und the script seizes to function. Now JavaScript istn't my strong suit, so I have been reading up on this for the last two hours, tried calling that function from a different place, tried to modify it, but no luck; the error remains the same (or slightly different; if I point at the class in question directly, the function doesnt work...). I would appreciate any advice you could give. Hi, a friend of mine has a problem on several (German) Legend of the Green Dragon (lotgd) servers. Sometimes, mostly after she has loged in and out for a few times during a day, she suddenly gets the message that Javascript must be enabled to log in. But it definetely IS enabled - otherwise she'd never be loged in! The error occurs - on 2 different PCs - with 2 different internet providers - with IE, FF and Opera - only on lotgd servers - any other page using Javescript are working fine We - updated and downgraded Javascript - disabled and/or uninstalled all antivirus and firewall programms - cleaned cache with CCleaner - disabled browser add ons - reinstalled Windows - disabled auto-insert passwords Even a reboot doesn't change anything. Sometimes, when she waits a few hours, she can log in again. Sometimes the error doesn't occur for days, sometimes it's there every day. That's why it is so strange. Although she doesn't change anything, the error comes and goes completely irregular. The games' admins can't or don't want to help, they say that she's the only one with that problem and that it's not a mistake in the script. What might occur that error? And what can we do to stop it?? That's what the Opera error console says: JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' CSS - http://lotgd.demonstone.org/templates/yarbrough.css Linked-in stylesheet xbackground-color is an unknown property Line 1: eight:auto;padding:1px;line-height:18px;float:left;clear:none;xbackground-color: --------------------------------------------------------------------------------^ JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' JavaScript - http://lotgd.demonstone.org/index.php Uncaught exception: ReferenceError: Undefined variable: calcMD5 Error thrown at line 1, column 0 in <anonymous function>(event): document.forms.loginform .hidden_pw.value = calcMD5(document.forms.loginform .password.value); JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' JavaScript - http://lotgd.demonstone.org/index.php Uncaught exception: ReferenceError: Undefined variable: calcMD5 Error thrown at line 1, column 0 in <anonymous function>(event): document.forms.loginform .hidden_pw.value = calcMD5(document.forms.loginform .password.value); JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' JavaScript - http://lotgd.demonstone.org/index.php Uncaught exception: ReferenceError: Undefined variable: calcMD5 Error thrown at line 1, column 0 in <anonymous function>(event): document.forms.loginform .hidden_pw.value = calcMD5(document.forms.loginform .password.value); JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' I hope someone is able to help. Thank you! First post here so... I have a few functions called by a form. Two examples are onclick in a form input and onkeyup in a form button. Code: function checkUsernameForLength(whatYouTyped) { var fieldset = whatYouTyped.parentNode; var txt = whatYouTyped.value; if (txt.length > 2) { fieldset.className = "welldone"; return true; } else { fieldset.className = ""; return false; } } Code: onkeypress="checkUsernameForLength(this);" There are a couple of the above "validation" functions. Each sets an input fieldset's class. Code: function verifyit() { var fieldsets = document.getElementsByTagName("fieldset"); var i=0; while (i<count(fieldsets)){ if (fieldsets[i] != "") { i++; document.form.submit(); } } } Code: onclick="verifyit()" The function above is where I'm having the trouble. I want to iterate through the fieldsets and make sure each class isn't blank before allowing the button to submit the form. I get an "object expected" error when I trigger the "verifyit" function with ie if it helps. I appreciate any input, thanks in advance for any help. 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" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Washington DC</title> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="scripts/downloadxml.js"></script> <style type="text/css"> html, body { height: 100%; } </style> <script type="text/javascript"> var side_bar_html = ""; var gmarkers = []; var map = null; function createMarker(latlng, name, html) { var contentString = html; var marker = new google.maps.Marker({ position: latlng, map: map, zIndex: Math.round(latlng.lat()*-100000)<<5 }); google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(contentString); infowindow.open(map,marker); }); // save the info we need to use later for the side_bar gmarkers.push(marker); // add a line to the side_bar html side_bar_html += '<a href="javascript:myclick(' + (gmarkers.length-1) + ')">' + name + '<\/a><br>'; } function myclick(i) { google.maps.event.trigger(gmarkers[i], "click"); } function initialize() { var myOptions = { zoom: 14, center: new google.maps.LatLng(38.897725,-77.036511), mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); google.maps.event.addListener(map, 'click', function() { infowindow.close(); }); // Read the data from Washington.xml downloadUrl("Washington.xml", function(doc) { var xmlDoc = xmlParse(doc); var marker = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var lat = parseFloat(marker[i].getAttribute("lat")); var lng = parseFloat(marker[i].getAttribute("lng")); var point = new google.maps.LatLng(lat,lng); var html = marker[i].getAttribute("html"); var label = marker[i].getAttribute("label"); // create the marker var POI = createMarker(point,label,html); } // put the assembled side_bar_html contents into the side_bar div document.getElementById("side_bar").innerHTML = side_bar_html; }); } var infowindow = new google.maps.InfoWindow( { size: new google.maps.Size(150,50) }); </script> </head> <body style="margin:0px; padding:0px;" onload="initialize()"> <table border="1"> <tr> <td> <div id="map_canvas" style="width: 1000px; height: 600px"></div> </td> <td valign="top" style="width:200px; text-decoration: underline; color: #4444ff;"> <div id="side_bar"></div> </td> </tr> </table> </body> </html> Hello, this is my first post. The following code works in FF, Is there any way to have the code work correctly in IE 7? The error is on both the following lines, odoc.appendChild(ne);. Thank you for any assistance. Quote: <!--#include file="include/dbcommon.asp"--> <% set dbConnection = server.CreateObject ("ADODB.Connection") dbConnection.ConnectionString = strConnection dbConnection.Open %> <html> <head> <link REL="stylesheet" href="include/style.css" type="text/css"> <!--[if IE]> <link REL="stylesheet" href="include/styleIE.css" type="text/css"> <![endif]--> </head> <body> <table> <tr><td> Subject:</td> <td><input id=subject type=text size=40></td> <td align=right> Templates: <select id=templates style="width:300" onchange="doInsert(document.getElementById('templates').value);document.getElementById('templates'). selectedIndex=0;"> <option value="">Please select</option> <% Set rs = server.CreateObject ("ADODB.Recordset") rs.Open "select * from QuickTemplates", dbConnection,1,2 while not rs.eof fname=replace(rs("fname"),"""",""") if(len(rs("fname"))>40) then _ fname=replace(left(rs("fname"),30)&"...","""",""") response.write "<option value=""" & replace(rs("fname"),"""",""") & """>" & fname & "</option>" rs.movenext wend rs.close %> </select> </td></tr> <tr> <td valign=top>Body:</td><td colspan=2><textarea id=body cols=100 rows=20></textarea></td> </tr> <td align=center colspan=3> <SPAN class=buttonborder><input class=button type=button value="Send email" onclick="sendem();"></SPAN> <SPAN class=buttonborder><input class=button type=button value="Close" onclick="self.close();return false;"></SPAN> </td> </tr> </table> </body> <html> <script> function sendem() { odoc=opener.document.getElementById("frmAdmin"); opener.document.forms.frmAdmin.a.value="email"; ne=document.createElement("input"); ne.name="subject"; ne.type="hidden"; ne.value=document.getElementById("subject").value; odoc.appendChild(ne); ne=document.createElement("input"); ne.name="body"; ne.type="hidden"; ne.value=document.getElementById("body").value; odoc.appendChild(ne); opener.document.forms.frmAdmin.submit(); self.close(); } function doInsert(ibTag) { var uagent = navigator.userAgent.toLowerCase(); var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") ); var is_opera = (uagent.indexOf('opera') != -1); var is_webtv = (uagent.indexOf('webtv') != -1); var ua_vers = parseInt(navigator.appVersion); var is_win = ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) ); var is_ie = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) ); if(ibTag!="") { var isClose = false; var obj_ta = document.getElementById("body"); obj_ta.focus(); if ( (ua_vers >= 4) && is_ie && is_win ) { var rng = document.selection.createRange(); rng.colapse; rng.text = ibTag; } else if ( obj_ta.selectionEnd>=0 ) { var ss = obj_ta.selectionStart; var st = obj_ta.scrollTop; var es = obj_ta.selectionEnd; if (es < 0) { es = obj_ta.textLength; } var start = (obj_ta.value).substring(0, ss); var end = (obj_ta.value).substring(es, obj_ta.textLength); obj_ta.value = start + ibTag + end; var p=0; var ent=0; while(p!=-1) { p=ibTag.indexOf('\n',p); if(p!=-1) { p++; ent++; } } var cpos = ss + (ibTag.length)-ent; obj_ta.selectionStart = cpos; obj_ta.selectionEnd = cpos; obj_ta.scrollTop = st; } obj_ta.focus(); return isClose; } } </script> import java.util.Scanner; public class Lab4_Ex2 { public static void main(String[] args) { String input; int firstTest; int secondTest; int thirdTest; int finalGrade; Scanner keyboard = new Scanner(System.in); // Get the fisrt test grade from the user System.out.print("Enter the first test grade: "); firstTest = keyboard.nextInt(); // Get the second test grade from the user System.out.print("Enter the second test grade: "); secondTest = keyboard.nextInt(); // Get the third test grade from the user System.out.print("Enter the third test grade: "); thirdTest = keyboard.nextInt(); if (firstTest < secondTest && firstTest < thirdTest) { finalGrade = secondTest + thirdTest; System.out.println("First Test: " + firstTest + "\nSecond Test: " + secondTest + "\nthirdTest: " + thirdTest); System.out.println("After dropping test 1, the final grade is " + finalGrade + "."); } else if (secondTest < firstTest && secondTest < thirdTest) { finalGrade = firstTest + thirdTest; System.out.println("First Test: " + firstTest + "\nSecond Test: " + secondTest + "\nthirdTest: " + thirdTest); System.out.println("After dropping test 2, the final grade is " + finalGrade + "."); } else if (thirdTest < firstTest && thirdTest < secondTest) { finalGrade = firstTest + secondTest; System.out.println("First Test: " + firstTest + "\nSecond Test: " + secondTest + "\nthirdTest: " + thirdTest); System.out.println("After dropping test 3, the final grade is " + finalGrade + "."); } if (finalGrade >= 90) System.out.println("The final letter grade is A."); else if(finalGrade < 90 && finalGrade >= 80) System.out.println("The final letter grade is B."); else if (finalGrade < 80 && finalGrade >= 70) System.out.println("The final letter grade is C."); else if (finalGrade < 70 && finalGrade >= 60) System.out.println("The final letter grade is D."); else if (finalGrade < 60) System.out.println("The final letter grade is F."); } } |