JavaScript - Error: Document.getelementbyid("vsbtitle_1") Is Null
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 Similar TutorialsHey all, For the below code, I'm just trying to create a simple toggle menu for a Table of Contents. However, when page loads, I get document.gelementbyid('sidebar') is null even though it's clearly there and if I move script to below markup, it will also give me a hideElements() is not a function error, even though it clearly is. Code: <script type="text/javascript"> (function(){ var headers = document.getElementById("sidebar").childNodes; for(var i=0; i < headers.length; i++){ hideElements(headers[i]); if(headers[i].nodeName == "h1"){ headers[i].childNodes[0].onclick = function(){ hideElements(headers[i]); this.parentNode.nextSibling.style.display = "block"; return false; } } } var hideElements = function(element){ if(element.nodeName == "UL") element.style.display = "none"; } })(); </script> <body> <a name="top"></a> <div id="masthead"> <h1>This is the Help Page</h1> </div> <div id="sidebar"> <h1><a href="chapter1"> Info</a></h1> <ul> <li><a href="#section1">Section 1</a></li> <li><a href="#section2">Section 2</a></li> <li><a href="#section3">Section 3</a></li> </ul> <h1><a href="chapter2"> Info</a></h1> <ul> <li><a href="#section4">Section 4</a></li> <li><a href="#section5">Section 5</a></li> <li><a href="#section6">Section 6</a></li> </ul> </div> <div id="content"> <h1 id="section1">Section 1</h1> <p> </p> <a href="#top">Back to Top</a> <h1 id="section2">Section 2</h1> <p> </p> <a href="#top">Back to Top</a> <h1 id="section3">Section 3</h1> <p> </p> <a href="#top">Back to Top</a> </div> </body> Thanks for any response. Quote: <html> <head> <script type="text/javascript"> var a = january var b = febuary var c = march function test() { document.getElementById("test").innerHTML=a; <!-- needs to be A on first function click, b on second, c on third, etc..^^--> } </script> </head> <body> <p id="test"></p> <!-- the <p> should go to next month upon each function --> <input type="button" value="asdf" onclick="test()" /> </body> </html> I tried to explain it pretty well in the comment tags, thanks! i have an onclick function, but after debuging i found that firefox and only firefox blocks at the line " individualNames = names.childNodes[0].innerText; " is there somthin im missing please help. function searchForm() { var change = 0; var searchValue = document.getElementById("searchValue").value.toLowerCase(); var count = document.getElementById("excelTable").rows.length; var once = true; myArray = new Array(); if(searchValue == ""){alert("Please enter a value"); return false} for(i=0;i<=count;i++){ names = document.getElementById("excelTable").rows[i]; individualNames = names.childNodes[0].innerText; //only by last name of the file coming in format == "LastName, FirstName" lastName = individualNames.split(", "); //only by last name lowerCaseNames = lastName[0].toLowerCase(); names.style.backgroundColor = "#FFF"; if(lowerCaseNames.indexOf(searchValue) != -1) { names.style.backgroundColor = "#999"; //make the first result with the search apear on screen than stop after the first if(once==true){document.getElementById("excelTable").rows[i].scrollIntoView(true); once=false;} myArray[change] = document.getElementById("excelTable").rows[i];//fill a passing array to next function change++;//make the array go to next slot document.getElementById("nextButton").disabled = false; document.getElementById("searchTitle").scrollIntoView(true); } } } Hi guys, i m novice to javascript, i have a piece of code to preview the image after selecting it from file upload control,its working fine in Firefox,but its not working in IE,Chorome,what is the error please let me know,here is my code. function setImage(file) { if (document.all) document.getElementById("<%=prevImage.ClientID %>").src = file.value; else document.getElementById("<%=prevImage.ClientID %>").src = file.files.item(0).getAsDataURL(); if (document.getElementById("<%=prevImage.ClientID %>").src.length > 0) document.getElementById("<%=prevImage.ClientID %>").style.display = 'block'; } Hi, first post here. I was working on code for opening a link in a new window when clicked. I read somewhere that it's a good idea to remove all of the javascript elements from the HTML. So I pieced it together and it works. But I get the following error in IE8: Code: Message: 'document.getElementById(...)' is null or not an object Here's the relevant HTML: Code: <a href="http://www.samplesite.com" id="sampleid">Sample Text</a> And here's the relevant javascript that I put in a seperate .js file: Code: function samplefct() { window.open(this.href);return false; } window.onload = function() {document.getElementById("sampleid").onclick = samplefct; } The code does work as planned. But I'd still like to get rid of the error. Can anybody think of a different way of stating the javascript that would perform the same thing and lose the error? Any help would be greatly appreciated. Thanks! IB 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> I'm at a complete loss as too what or where i've missed something. i only included 2 models out of the 1000's that will have pages like this...i should also note that will be shown in an iframe..don't know if that really makes a diference tho hope someone can figure out what i've missed Code: <script language="javascript"> top.document.reset.RefCat.value="Television"; top.document.reset.NarrowRef.value="Good"; top.document.reset.criteria.value="KD"; top.document.reset.searchscope.value=""; top.document.reset.companyscope.value=""; top.document.reset.company.value=""; if(""==""){top.reset();} function popUp(URL,Name) { var day = new Date(); var id = "page" + Name; window.open(URL, id, "toolbar=1,scrollbars=1,location=0,statusbar=1, menubar=0,resizable=1,width=600,height=600"); } function launchjsmanuals(flag, x, y, z, id) { //var myTypeLib = new ActiveXObject("Scriptlet.Typelib"); //var GUID = new String(myTypeLib.guid).substr(1,8); //var endguid = new String(myTypeLib.GUID).substr(25,10); if((x.indexOf("CHM")!=-1) || (x.indexOf("chm")!=-1)){ alert("You will be prompted to download a file\n\nClick Open - Do NOT click Save"); } var whnd = "page" + id; //+ GUID + endguid; var URL = 'philips.asp?flag='+flag+'& manual=' + x + '&user=' + y + z + '&manualid=' + id; if(flag!=""){ whnd = window.open(URL,whnd, "toolbar=0,scrollbars=1,location=0,statusbar=0, menubar=0,resizable=1,width=560,height=600"); }else{ whnd = window.open(URL,"Loader", "toolbar=0,scrollbars=1,location=0,statusbar=0, menubar=0,resizable=1,width=560,height=600"); } } function NarrowSearch(what,value,cat){ switch(what){ case "Model": if("Television"!=""){ parent.document.SearchForm.RefCat.value="Television"; } parent.document.SearchForm.criteria.value=value; parent.document.SearchForm.searchscope.value="model"; parent.document.SearchForm.NarrowRef.value="Good"; parent.document.SearchForm.submit() break; </script> </head> <body> <div id="results"> <table border=0 cellpadding=0 cellspacing=2><tr><td><a class="modellink" onMouseOver="this.className='modellinkhover'" onMouseOut="this.className='modellink'" onclick="javascript:NarrowSearch('ONLY','KDLV40A10',' Television')"><b>KD</b>LV40A10</a></td> <td width=15px></td><td><a class="modellink" onMouseOver="this.className='modellinkhover'" onMouseOut="this.className='modellink'" onclick="javascript:NarrowSearch('ONLY','KDLV40XBR1',' Television')"><b>KD</b>LV40XBR1</a></td> <td width=15px></td></tr></table</div></div></div></table> <!-- <FORM NAME="displayaction" ACTION="directview.asp" METHOD="POST" target="_salert"> --> <FORM NAME="displayaction" ACTION="_directview.asp" METHOD="POST" target="_salert"> <INPUT type="hidden" name="id" value=""> <INPUT type="hidden" name="actionurl" value=""> <INPUT type="hidden" name="modelnum" value=""> </form> <iframe name="Loader" id="Loader" src="blank.htm" style="display:none;height:150px; width:100%;border:1px solid silver"></iframe> <a onclick="document.getElementById('Loader').style.display='';">*</a> <script language="javascript"> //alert(parent.IQ.location.href); </script> </body> </html> . SOURCE: Here Code: 1 document.onmousemove = mouseMove; 2 3 function mouseMove(ev){ 4 ev = ev || window.event; 5 var mousePos = mouseCoords(ev); 6 } 7 8 function mouseCoords(ev){ 9 if(ev.pageX || ev.pageY){ 10 return {x:ev.pageX, y:ev.pageY}; 11 } 12 return { 13 x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, 14 y:ev.clientY + document.body.scrollTop - document.body.clientTop 15 }; 16 } #1: How is it that "mouseMove" is assigned to "document.onmousemove" from right-to-left? What exactly is taking place here? #3: How can "mouseMove" be declared as a function afterwards? #3: I periodically see "e" being placed in functions. Is "ev" taking the place for "e"? If so is "ev" or "e" a global object? Where do they initially come from and how do they work? . Hi....I have an error in my script, but idk where it is..... here is the script: Code: <script type="text/javascript"> var browser = navigator.appName; if (browser=="Netscape") { document.getElementById(msg).style.display="none"; } </script> <div id="msg" style="width:100%;padding:3px;position:fixed;top:0px;left:0px;background:red;">Please install <a href="http://www.mozilla.org/sk/firefox/">Mozilla Firefox</a> to view this page normally.</div> Below are the full Javascript and HTML to detect a browser and either display HTML5 or Flash video. However, the script is returning an error, 'document.getElementById(...)' is null or not an object. Any suggestions? Code: var deviceAgent = navigator.userAgent.toLowerCase(); $brwzr = deviceAgent.match(/(chrome|firefox|safari|msie 9.0)/); if ($brwzr) { document.getElementById("video_5").setAttribute("class", "on"); } else { document.getElementById("video_F").setAttribute("class", "on"); } Code: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Video Switch</title> <script language="JavaScript" src="index/js/detect.js"></script> <style> <!-- .off { display: none; } .on { display: inline; } --> </style> </head> <body> <div id="video_5" class="off">HTML5!</div> <div id="video_F" class="off">Flash!</div> </body> </html> Hi, I am trying to show and hide different div objects on a webpage all with different ID's as you can see. Only the first object will work "('killstreakwin')", or any that is put first, none of the others work after that. It's not the HTML side, it's definatly the javascript function. I've tried to use a loop but I don't know how to implement it into something like this. Any help would be appreciated. This is the code I am using:- function windowOpen() { (document.getElementById('killstreakwin').style.visibility='visible'); (document.getElementById('standardwin').style.visibility='visible'); (document.getElementById('hardenedwin').style.visibility='visible'); (document.getElementById('veteranwin').style.visibility='visible'); (document.getElementById('prestigewin').style.visibility='visible'); (document.getElementById('perkswin').style.visibility='visible'); (document.getElementById('copycatwin').style.visibility='visible'); (document.getElementById('martyrdomwin').style.visibility='visible'); (document.getElementById('finalstandwin').style.visibility='visible'); (document.getElementById('painkillerwin').style.visibility='visible'); (document.getElementById('rankswin').style.visibility='visible'); (document.getElementById('prestigewin').style.visibility='visible'); (document.getElementById('primarywin').style.visibility='visible'); (document.getElementById('secondarywin').style.visibility='visible'); (document.getElementById('attachmentswin').style.visibility='visible'); } function windowClose() { (document.getElementById('killstreakwin').style.visibility='hidden'); (document.getElementById('standardwin').style.visibility='hidden'); (document.getElementById('hardenedwin').style.visibility='hidden'); (document.getElementById('veteranwin').style.visibility='hidden'); (document.getElementById('prestigewin').style.visibility='hidden'); (document.getElementById('perkswin').style.visibility='hidden'); (document.getElementById('copycatwin').style.visibility='hidden'); (document.getElementById('martyrdomwin').style.visibility='hidden'); (document.getElementById('finalstandwin').style.visibility='hidden'); (document.getElementById('painkillerwin').style.visibility='hidden'); (document.getElementById('rankswin').style.visibility='hidden'); (document.getElementById('prestigewin').style.visibility='hidden'); (document.getElementById('primarywin').style.visibility='hidden'); (document.getElementById('secondarywin').style.visibility='hidden'); (document.getElementById('attachmentswin').style.visibility='hidden'); } ok so Code: document.write("Goodbye!"); works but I put ^ that inside a function Code: function SayHello () ( document.write("Goodbye!"); ) and it stops working? I know the function call works because when I place some code to display an image in SayHello function, it displays the image. Can someone explain what this does? Code: ... <script language=\"Javascript\" type=\"text/javascript\"> function SecCheck(t) { if(t) refresh = setTimeout(\"document.location='index.php';\", t*1000); } </script> </head> <body onLoad=\"SecCheck(30)\"> ... Hiya, I would like to ask your help regarding this damned error message that comes out only in Internet Explorer and makes impossible to submit the form. The javascript code is: Code: function checkForm() { var cname, cspouse, cemail, chphone, ccellular, caddress, ccity, cstate, czip, cpets, cvolunteer, cadditional; with(window.document.volApplForm) { cname = Name; cspouse = Spouse; cemail = Email; chphone = HomePhone; ccellular = Cellular; caddress = Address; ccity = City; cstate = State; czip = Zip; cpets = Pets; cvolunteer = Volunteer; cadditional = Additional; } var ALERT_TITLE = "Oops!"; var ALERT_BUTTON_TEXT = "Close"; if(document.getElementById) { window.alert = function(txt) { createCustomAlert(txt); } } function createCustomAlert(txt) { d = document; if(d.getElementById("modalContainer")) return; mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div")); mObj.id = "modalContainer"; mObj.style.height = document.documentElement.scrollHeight + "px"; alertObj = mObj.appendChild(d.createElement("div")); alertObj.id = "alertBox"; if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px"; alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px"; h1 = alertObj.appendChild(d.createElement("h1")); h1.appendChild(d.createTextNode(ALERT_TITLE)); msg = alertObj.appendChild(d.createElement("p")); msg.innerHTML = txt; btn = alertObj.appendChild(d.createElement("a")); btn.id = "closeBtn"; btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT)); btn.href = "#"; btn.onclick = function() { removeCustomAlert();return false; } } if(trim(cname.value) == '') { alert('Please enter your name'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); cname.focus();} return false; } else if(trim(cemail.value) == '') { alert('Please enter your email'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); cemail.focus();} return false; } else if(!isEmail(trim(cemail.value))) { alert('Email address is not valid'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); cemail.focus();} return false; } else if(trim(chphone.value) == '') { alert('Please enter your valid phone number'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); chphone.focus();} return false; } else if(trim(ccellular.value) == '') { alert('Please enter valid cell phone number'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); ccellular.focus();} return false; } else if(trim(caddress.value) == '') { alert('Please enter your valid address'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); caddress.focus();} return false; } else if(trim(ccity.value) == '') { alert('Please enter your city'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); ccity.focus();} return false; } else if(trim(cstate.value) == '') { alert('Please enter valid state name'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); cstate.focus();} return false; } else if(trim(czip.value) == '') { alert('Please enter valid zip code'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); czip.focus();} return false; } else if(trim(cvolunteer.value) == '') { alert('Please fill in all fields'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); cvolunteer.focus();} return false; } else if(trim(cadditional.value) == '') { alert('Please fill in all fields'); function removeCustomAlert() {document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); cadditional.focus();} return false; } else { cname.value = trim(cname.value); cspouse.value = trim(cspouse.value); cemail.value = trim(cemail.value); chphone.value = trim(chphone.value); ccellular.value = trim(ccellular.value); caddress.value = trim(caddress.value); ccity.value = trim(ccity.value); cstate.value = trim(cstate.value); czip.value = trim(czip.value); cpets.value = trim(cpets.value); cvolunteer.value = trim(cvolunteer.value); cadditional.value = trim(cadditional.value); return true; } } function trim(str) { return str.replace(/^\s+|\s+$/g,''); } function isEmail(str) { var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn |bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk| dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs |gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr| kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum |mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr |pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf |tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za| zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i; return regex.test(str); } And when trying to submit the form, I get the error message: Code: Line: 177 Character: 4 Code: 0 Error Message: 'undefined' is null or not an object URL: https://localhost/ruff/scripts/validationVol.js Do you have an idea what could be the problem? As I checked line 177, it seems to be OK. I checked the web, but didn't find anything related to this message in a situation like this. Thanks in advance for your comments. Though I took out the source of the iframe, I get an error when I click the test button to get the value of msg_title. I am using IExplorer to debug it, as firefox doesnt show the error. Code: <script type='text/javascript'> function test(){ page = window.location.href document.getElementById('1').value = window.frames[2].document.getElementByName('msg_title').value } function apple(){ document.getElementById('3').innerHTML = '<iframe src="" name="4" id="4"></iframe>' } window.onLoad = test(); </script> <div id='3' name='3'></div> <input type='button' value='apple' name='apple' id='apple' onclick='apple()'> <input type='button' value='test' name='test' id='test' onclick='test()'> <input type='text' value='' name='1' id='1'> <br> <iframe src='' name='2' id='2'> Hi, the following does not work in firefox, note that I have removed the < at the beggining of the script in order to see what was being written, what I am trying to acheive is to write the following to an IFRAME using JavaScript, on click of a button: PHP Code: <script language=javascript type="text/javascript" runat=server> var fso = new ActiveXObject("Scripting.FileSystemObject"); var f = fso.OpenTextFile("somefile.txt", 2, true); f.WriteLine('lblTitle="Color Setup"'); f.WriteLine('scmdSave="Save"'); f.Close();</Script> in order to get this, I wrote a script that goes like this: PHP Code: var frTraductionID = document.getElementById("frTraduction"); frTraductionID = (frTraductionID.contentWindow) ? frTraductionID.contentWindow : (frTraductionID.contentDocument.document) ? frTraductionID.contentDocument.document : frTraductionID.contentDocument; var x=frTraductionID.document.getElementById("hCount").value; var ifrm = document.getElementById("ifUPDATE"); ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument; ifrm.document.open(); ifrm.document.write('scr' + 'ipt language=javascript type="text/javascript" runat=server>'); ifrm.document.write('var fso = new Active' + 'XObject("Scripting.FileSystemObject"); '); ifrm.document.write('var f = fso.OpenTextFile("' + sFileName + '", 2, true); '); for (var i=0;i<x;i+=1) { var sString=""; sString +="f.WriteLine('"; sString +=frTraductionID.document.getElementById("h"+i).value; sString +='="'; sDetail=frTraductionID.document.getElementById("d"+i).value.replace('"', ' '); sDetail=sDetail.replace("'", "`"); sString +=sDetail; sString +='"'; sString +="')"; sString +="; "; alert("i = " + i + " str = " + sString); ifrm.document.write(sString); } ifrm.document.write("f.Close();"); ifrm.document.write("<"); ifrm.document.write("Scr"); ifrm.document.write("ipt>"); ifrm.document.close(); document.getElementById('ifUPDATE').contentWindow.location.reload(true); The problem is that the "<" seam to cause problem, I have intentionally removed the first < in order to see what the result was and here is what I get: PHP Code: script language=javascript type="text/javascript" runat=server>var fso = new ActiveXObject("Scripting.FileSystemObject"); var f = fso.OpenTextFile("//ADMNPC88/VIP/Language/TEST5/COLOR_SETUP.INC", 2, true); f.WriteLine('lblTitle="Color Setup"'); f.WriteLine('scmdSave="Save"'); f.WriteLine('scmdRestore="Restore"'); f.WriteLine('lblControlHeader="Control`s Header"'); f.WriteLine('lblControlDetail="Control`s Detail"'); f.WriteLine('lblControlDetailHL="Control`s Detail Highlighted"'); f.WriteLine('lblLettering="Lettering"'); f.WriteLine('lblHelp="Drag and drop the desired color on the part of the screen for which you want to change the color."'); f.Close(); Note that I am missing the whole tail end </Script> Please help as I cannot figure it out. Thank you hello everyone, I've been trying to build a simple dynamic menu using js and came across the IE getElementById() bug. IE does not accept the elements attributes. Is there another way for going around this? Been struggling with it for weeks now. Any sort of help would be most appreciated. Nivi. I am testing the contents of e.min for null, this works in everything except the latest version of Safari and Chrome. In the latest versions if I test for "" it works correctly but this does not work in IE, Firefox or older versions of Safari. e.min has not been set to anything. For now I have fixed the problem by omitting the test but I would like to know if it is possible to implement a real fix.
|