JavaScript - My Code Works In Google Chrome, But Not Firefox!
this code works in google chrome, but not in firefox.
Code: function merge(obj1, obj2) { var a ={}; for (var p in obj1) { try { // Property in destination object set; update its value. if ( obj1[p].constructor==Object ) { a[p] = merge(a[p], obj1[p]); } else { a[p] = obj1[p]; } } catch(e) { // Property in destination object not set; create it and set its value. a[p] = obj1[p]; } } for (var p in obj2) { try { // Property in destination object set; update its value. if ( obj2[p].constructor==Object ) { a[p] = merge(a[p], obj2[p]); } else { a[p] = obj2[p]; } } catch(e) { // Property in destination object not set; create it and set its value. a[p] = obj2[p]; } } return a; } var d=function(){'c';} var a ={a:{b:'c'},b:'c'} var b ={c:a,d:d}; var c = merge(window,b); WHY?!?!?!?!?!?!?!?!?!?!?!?!??!?!?!?! Similar TutorialsHi, can anyone help me with this? The following html is to upload an image, it works ok on firefox, but while using google chrome, nothing happened when I clicked "upload LOGO" button. .................................................................................................... .... <html> <body> <form method="post" action="action_start_initial_registration.php" name="initial_registration" id="initial_registration" enctype="multipart/form-data"> <input type="file" style="display:none" onchange="checkLogo()" name="input_logo_file" id="input_logo_file" value="input_logo_file"> <input type="text" name="logo_flag" id="logo_flag" value="0" style="display:none;"/> <a href="javascript:void(0);" onclick="input_logo_file.click()"><em>upload LOGO</em></a><br /> </form> <script type="text/javascript"> function checkLogo(){ document.getElementById("logo_flag").value="1"; document.getElementById("initial_registration").submit(); } </script> </body> </html> ............................................................................................. Can anyone tell me why the following works in IE but not the other browsers? It's the "Select category..." jump menu at this URL: www.savasbeatie.com/books.htm Code: <TD> <form name="whichCat" style="margin-bottom:0" method="get"> <select name="catChoice" onChange="sendValue(this);"> <option class="news4" value="javascript:location.reload(true)" selected>Select Category...</option> <option class="news4" value="php/IraqWars.php?q=Iraq%20Wars">Iraq Wars/Current Affairs</option> <option class="news4" value="php/AncientHistory.php?q=Ancient%20History">Ancient History</option> <option class="news4" value="php/AmericanRevolution.php?q=American%20Revolution">American Revolution</option> <option class="news4" value="php/NapoleonicWar.php?q=Napoleonic%20War">Napoleonic War</option> <option class="news4" value="php/AmericanCivilWar.php?q=American%20Civil%20War">American Civil War</option> <option class="news4" value="php/IndianWars.php?q=Indian%20Wars">Indian Wars</option> <option class="news4" value="php/WorldWars.php?q=World%20Wars">World Wars</option> <option class="news4" value="php/Naval.php?q=Naval">Naval</option> <option class="news4" value="php/MilitaryScience.php?q=Military%20Science">Military Science</option> <option class="news4" value="php/SportsHistory.php?q=Sports%20History">Sports History</option> <option class="news4" value="php/Other.php?q=Other">Other</option> </select> </form> </TD> I've been called in to help with this, but did not build the site. There's a frame that's supposed to display the link contents, and it's returning the error: Error: document.getElementById("SB_Frame") is null Source File: http://savasbeatie.com/jscripts/SB_util.js Line: 11 I think it has something to do with the ID of the frame, (from Googling the error and reading some other posts,) but can't figure out where to put the tag. Thanks for any help. - David The following script grabs a string (*.abc.org, e.g. from &sid=xyz.abc.org) from the current URL and changes it (to ABC:abc.org). Everything works perfectly in IE, but Firefox and Chrome appear to get themselves into an endless loop. When I check the URL, xyz.abc.org has successfully been changed to ABC:abc.org, but the page just seems to keep refreshing over and over. Code: var tomatch = /abc.org/i; var usrString = document.referrer; var is_a_match = tomatch.test(usrString); var newString = document.URL.replace(/[a-z]*\.abc\.org/, "ABC:abc.org"); if (is_a_match) { window.location.replace(newString); } Any suggestions much appreciated. ok so ive nearly finished the animated javascript in my site. http://calumk.com/ to see the effect launch in chrome or safari, it works fine.. but its not working in Firefox (and i havent tested IE.. if someone could, i would appreciate it) i have no-idea why.. . im using the http://berniecode.com/writing/animator.html library which works fine in all browsers.. Any help would be apreciated... I would post the code, but its probably easier if you just view source Title explains it really. The button I am using working perfecting in FireFox and Chrome but not in Internet explorer. (Yes I know someone that actually uses IE that pointed this out to me) The rest of the code works fine but just not the reset button I have. Something I have been needing to do is make the code call my images differently by putting them in an array so I don't mess this the sources of my images like I sloppily am here, but I am not sure if that will actually fix the problem I am have. The checkbox should both uncheck the box(if checked) AND change the picture but it only unchecks the box. Here is the relevant code let me know if you want me to post the whole thing. Code: function reset(){ cb1.checked=false; document.goodAfternoon.src=goodAfternoonFinal.src; } Code: "Check" me out;) <input type="checkbox" id="cb1" onClick="validate()" /> <img src="Good Afternoon.gif" name="goodAfternoon"> <input type="button" id="cb2" value="RESET" onClick="reset()"/> Hi, This code uses the getElementById to change the background of certain <tr>'s. In a nutshell there are two buttons, the code checks which one has been clicked, then checks the background colour of a relevant <tr> and depending what it finds changes the colours of the cells. Works fine in Chrome and Firefox but not in IE and I'm now sorely vexed by it. Can anyone shed light on the solution please? Code: <script language="javascript" type="text/javascript"> function changeBackgroundColor(objDivID) { var backColor = new String(); if ( objDivID == "lifesciences" ) { backColor = document.getElementById('claire').style.backgroundColor; } if ( objDivID == "healthcare" ) { backColor = document.getElementById('adrienne').style.backgroundColor; } if(backColor.toLowerCase()=='#ffffff' || backColor.toLowerCase()=='rgb(255, 255, 255)') // IE works with hex code of color e.g.: #eeeeee // Firefox works with rgb color code e.g.: rgb(238, 238, 238) // Thats why both types are used in If-condition below { if ( objDivID == "lifesciences" ) { document.getElementById('david').style.backgroundColor = '#c0c0c0'; document.getElementById('claire').style.backgroundColor = '#c0c0c0'; document.getElementById('adrienne').style.backgroundColor = '#ffffff'; document.getElementById('karen').style.backgroundColor = '#c0c0c0'; document.getElementById('alice').style.backgroundColor = '#c0c0c0'; document.getElementById('kelly').style.backgroundColor = '#ffffff'; document.getElementById('sarah').style.backgroundColor = '#c0c0c0'; document.getElementById('carolyn').style.backgroundColor = '#c0c0c0'; document.getElementById('paul').style.backgroundColor = '#c0c0c0'; document.getElementById('kayleigh').style.backgroundColor = '#c0c0c0'; document.getElementById('tim').style.backgroundColor = '#c0c0c0'; document.getElementById('chantal').style.backgroundColor = '#c0c0c0'; document.getElementById('lee').style.backgroundColor = '#c0c0c0'; document.getElementById('lisa').style.backgroundColor = '#c0c0c0'; } else { document.getElementById('david').style.backgroundColor = '#c0c0c0'; document.getElementById('claire').style.backgroundColor = '#ffffff'; document.getElementById('adrienne').style.backgroundColor = '#c0c0c0'; document.getElementById('karen').style.backgroundColor = '#c0c0c0'; document.getElementById('alice').style.backgroundColor = '#c0c0c0'; document.getElementById('kelly').style.backgroundColor = '#c0c0c0'; document.getElementById('sarah').style.backgroundColor = '#c0c0c0'; document.getElementById('carolyn').style.backgroundColor = '#ffffff'; document.getElementById('paul').style.backgroundColor = '#ffffff'; document.getElementById('kayleigh').style.backgroundColor = '#ffffff'; document.getElementById('tim').style.backgroundColor = '#c0c0c0'; document.getElementById('chantal').style.backgroundColor = '#c0c0c0'; document.getElementById('lee').style.backgroundColor = '#c0c0c0'; document.getElementById('lisa').style.backgroundColor = '#c0c0c0'; } } else { document.getElementById('david').style.backgroundColor = '#ffffff'; document.getElementById('claire').style.backgroundColor = '#ffffff'; document.getElementById('adrienne').style.backgroundColor = '#ffffff'; document.getElementById('karen').style.backgroundColor = '#ffffff'; document.getElementById('alice').style.backgroundColor = '#ffffff'; document.getElementById('kelly').style.backgroundColor = '#ffffff'; document.getElementById('sarah').style.backgroundColor = '#ffffff'; document.getElementById('carolyn').style.backgroundColor = '#ffffff'; document.getElementById('paul').style.backgroundColor = '#ffffff'; document.getElementById('kayleigh').style.backgroundColor = '#ffffff'; document.getElementById('tim').style.backgroundColor = '#ffffff'; document.getElementById('chantal').style.backgroundColor = '#ffffff'; document.getElementById('lee').style.backgroundColor = '#ffffff'; document.getElementById('lisa').style.backgroundColor = '#ffffff'; } } </script> I had to develop a word game for a class project. The final is revolving around this class project but I was marked down some points for this project. I need to find out what I did wrong so I can pass my Final Exam. The program passed Google Chrome and Safari, but the teacher said it didn't pass Firefox Error Console. Any pointers will help. <html> <head> <title> Project </title> <script type="text/javascript" src="http://balance3e.com/random.js"></script> <script type="text/javascript"> function GetLetter() // Assumes: There are 5 letters // Results: Returns a single letter { var letter letter = RandomOneOf(['a', 'e', 'l', 'm', 'n']); return letter; } </script> <script type="text/javascript"> function GetWord(lastLetter) // Assumes: There is a letter the user has selected // Results: Returns a four letter word ending with the letter the user has selected { var word lastLetter = document.getElementById('lastLetter').value word = ''; l = 0; while (l < 3) { word = word + GetLetter(); l = l + 1; } return word + lastLetter; } </script> <script type="text/javascript" src="http://balance3e.com/random.js"></script> <script type="text/javascript"> function CheckWord(word) // Assumes: The user entered a word // Results: Will check to see if the word matched the winning word { var cWord cWord = false; if (word=="lane" || word=="lean" || word=="mama" || word=="meal" || word=="name") { cWord = true; } return cWord } </script> <script type="text/javascript"> function trytowin() // Assumes: The user returned a true or false answer // Results: Will Check to see if the user has won or lost { var word, t = 0; document.getElementById('winningWord').value = ""; document.getElementById('winLoss').value = 'Lose'; document.getElementById('lowords').innerHTML = ''; valid = false; while (t < 20 && valid == false) { word = GetWord(lastLetter); valid = CheckWord(word); document.getElementById('lowords').innerHTML = document.getElementById('lowords').innerHTML + word + '<br>'; t = t + 1; if (valid == true) { document.getElementById('winningWord').value = word; document.getElementById('winLoss').value = 'Won after ' + t + ' times!'; } } } </script> </head> <body> <p> Your word is: <input type="text" id="winningWord" size=10><br> You: <input type="text" id="winLoss" size=20><br> Type in a letter chosen from a,e,l,m,n <input type="text" id="lastLetter" size=2 value=""> Press the button to get a word ending with that letter and see if you won<input type="button" value="Try to Win!" onclick="trytowin();"> <hr> <div id="lowords"></div> </body> </html> I'm just starting JavaScript and wrote a quick script for Next/Back buttons for a page showing a family outing on our boat. I proudly uploaded the webpage and emailed it out, but people running IE are unable to use the buttons, they simply do nothing. Here is the .js file, I don't think anything in the HTML or CSS is causing the issue but could post those as well if necessary. Code: var step = 1; //preload images var numImages = 13; var images = new Array( numImages ); var i = 0; for ( i = 0; i < numImages; i++ ) { images[i] = new Image(); images[i].src = "images/boat" + ( i + 1 ) + ".jpg"; } function back() { if( step > 1 ) { step--; } else { step = numImages; } document.images.slide.src = images[step-1].src; } function next() { if( step < numImages ) { step++; } else { step = 1; } document.images.slide.src = images[step-1].src; } function init() { document.getElementById("back").onclick = back; document.getElementById("next").onclick = next; } window.onload = init; I've checked a lot of sites and can't figure this one out. Also, if I'm practicing any bad coding techniques, I'm open to suggestions on that as well It works in Google Chrome but not Firefox and Internet Explorer. My computer has blocked Opera and I don't know how to change that. Too much energy to investigate now, I'll do so later. Are there any pros that can tell me why this is happening? I'm assuming GoogleChrome is fixing a syntax error that FF and IE don't. Code: var request; request=false; try { request = new XMLHttpRequest(); } catch (trymicrosoft) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { request = false; } } } function isAlNum(str){ return /^[a-z0-9]+$/i.test(str); } var preUsername; var same; function updatePage() { if (username.value.length>0){ if ( request.responseText.indexOf("0") == -1 ) {userNameErrorBox.innerHTML=username.value + " has already been taken"; usernameSuccessBox.innerHTML="";} else {userNameErrorBox.innerHTML=""; usernameSuccessBox.innerHTML=username.value + " is available";}} } function nameTest() { if (username.value==preUsername) {same=1;} else {same=0;} if (!isAlNum(username.value)) {if (username.value.length>0) {username.value=preUsername;}} else {preUsername=username.value;} if (username.value.length>0 && username.focus && same===0) { userNameErrorBox.innerHTML="";usernameSuccessBox.innerHTML=""; request.abort(); var url = "/unseen/checkIfUserNameExist.php?name=" + username.value; request.open("GET", url, true); request.onreadystatechange = updatePage; request.send(null); } if (username.value.length===0) { userNameErrorBox.innerHTML="";usernameSuccessBox.innerHTML="";preUsername=""; } } I back tracked what i did and it appears that this code Code: var url = "/unseen/checkIfUserNameExist.php?name=" + username.value; request.open("GET", url, true); request.onreadystatechange = updatePage; request.send(null); has the problem. When I set up alerts to see what works and what doesn't, this code seems to be causing the FF and IE to not work, but I can't tell what it is that's causing them to fail. This is javascript that is suppose to check if a name has been taken by another user. I'm working on a fairly large project that I wish to be the new formspring, (size wise) I procrastinated for 2 weeks of my 12 week break and now that I'm just getting started on it I'm running into an ishness load of problems... Very de-motivating I'm new to the forum. So hi everyone. The code below works fine on IE and FF but not on Google Chrome. Can someone tell me where I'm doing wrong? Thank you for your answers in advance. Im really looking forward much to hearing from you. You can preview the below code by pasting it to Frontpage, Dreamweaver and etc. Quote: <!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> <script type="text/JavaScript"> <!-- function show(id) { if (document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = ''; } } //--> <!-- function hide(id) { document.getElementById(id).style.display = 'none'; } //--> </script> </head> <body> <div> <div> <table cellspacing="1" cols="3" border="0"> <tbody> <td><a onfocus="hide('tblB');hide('tblC');show('tblA');" href="#">A</a> <td><a onfocus="hide('tblA');hide('tblC');show('tblB');" href="#">B</a> <td><a onfocus="hide('tblB');hide('tblA');show('tblC');" href="#">C</a> </td> </tr> </tbody> </table> </div> <div> <table id="tblA" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select A, table tblA is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblB" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select B, table tblB is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblC" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select C, table tblC is shown </td> </tr> </tbody> </table> </div> </div> </body> </html> I am ripping my hair out trying to figure out why my innerHTML code is not working. It only works in IE, but keeps failing in Chrome and Firefox. I am using a form text field for customers to enter a Gallery ID (text value in the form field) which I have set up for them in an external js file. I use this code to change the content of div's after it checks the js file for a matching text value. Here is what is happening-- the proper content shows up for a second in Chrome or Firefox if the username value matches, but it pops away really fast and goes back to the login field prompt. Javascript: Code: <head> <script type="text/javascript"> function setinitialvalues(){ document.getElementById('loginblock').style.visibility = 'visible'; document.getElementById('galleryinfo2').style.visibility = 'hidden'; document.getElementById('expiredmessage').style.visibility = 'hidden'; document.getElementById('republish').style.visibility = 'hidden'; document.getElementById('logoutmessage').innerHTML = ""; document.getElementById('logoutmessage2').innerHTML = ""; document.getElementById('logoutmessage').style.visibility = 'hidden'; document.getElementById('logoutmessage2').style.visibility = 'hidden'; } </script> <script type="text/javascript"> function loadcustomer(){ document.getElementById('galleryinfo').innerHTML = ""; document.getElementById('galleryinfo2').innerHTML = ""; document.getElementById('expdatemessage').innerHTML = ""; document.getElementById('expiredmessage').innerHTML = ""; document.getElementById('republish').innerHTML = ""; document.getElementById('logoutmessage').style.visibility = 'hidden'; document.getElementById('logoutmessage2').style.visibility = 'hidden'; document.getElementById('loginblock').innerHTML = "<br /><h4>If you know your Gallery ID, you can enter it here to access your proofing gallery and order page.<br /><br />ENTER GALLERY ID:</h4><form name='form' action='' method='post'><input style='color:#000;' name='username' id='username' onfocus='clearinvalid()' onKeyDown='clearinvalid()'><br /><br /><input style='background-color:#33A1C9;' class='button' id='submitbutton' type='submit' value='Submit' onClick='return galleryid(this.form)'></form><h4><div style='color:#ff0000;' id='invalidmessage'></div></h4><br />Sample Gallery ID: demo<br />(Then click the Submit button. Some browsers do not accept the Enter key.)<br /><br /><a href='#' class='btn btn-lg btn-default'>Back to Menu</a><br /><br />This works on Internet Explorer, Firefox, Opera and Google Chrome. Please use one of these web browsers to log in."; document.getElementById('loginblock').style.visibility = 'visible'; } </script> <script language="javascript" type="text/javascript" src="customergallery.js"></script> </head> HTML: Code: <div style="text-align:center;" id="loginblock"></div> <div id="galleryinfo"></div> <div id="galleryinfo2"></div> <div style="color:#ff0000;" id="expdatemessage"></div> <div style="color:#ff0000;" id="expiredmessage"></div> <div id="republish"></div> <div id="logoutmessage"></div> <div id="logoutmessage2"></div> External customer js file: Code: function Submit(){ if(event.keyCode == 13) { galleryid(); return false; } } function galleryid(){ if (document.getElementById('username').value == 'demo') { var name = "My Photomatic Photo Session"; var sessiondate = "02/22/2014"; var location = "Any town, USA"; var orderlink = "<a href='../../accounts/brown/20140222/myphotomatic20140222.html' target='_blank'>CLICK HERE TO VIEW GALLERY</a>"; var todayDate = new Date(); var expdate = new Date(2015,05,30); comparedate(); } else if (document.getElementById('username').value == '') { document.getElementById('invalidmessage').innerHTML = 'Please enter a value in this field.'; } else { document.getElementById('invalidmessage').innerHTML = 'Invalid Gallery ID. Please try again.'; } document.getElementById('username').value = ""; return false; function comparedate() { if (todayDate >= expdate) { document.getElementById('galleryinfo2').innerHTML = "<br /><br />" + name + "<br />Session Date: " + sessiondate + "<br />" + location + "<br /><br />"; document.getElementById('expiredmessage').innerHTML = "This gallery has expired on " + (expdate.getMonth()+1) + "/" + expdate.getDate() + "/" + expdate.getFullYear(); document.getElementById('republish').innerHTML = "<br />If you would like to have this gallery republished, please email me .<br /><br />"; document.getElementById('logoutmessage2').innerHTML = "<a href='javascript:void(0);' onclick='loadcustomer(); clearusername(); setinitialvalues();' class='btn btn-lg btn-default'>Click here to return to the Login</a><br /><br />"; document.getElementById('galleryinfo2').style.visibility = 'visible'; document.getElementById('expiredmessage').style.visibility = 'visible'; document.getElementById('republish').style.visibility = 'visible'; document.getElementById('logoutmessage2').style.visibility = 'visible'; document.getElementById('loginblock').innerHTML = ""; document.getElementById('loginblock').style.visibility = 'hidden'; } else { loadcustomer(); document.getElementById('galleryinfo').innerHTML = "<br /><br />" + name + "<br />Session Date: " + sessiondate + "<br />" + location + "<br /><br />" + orderlink + "<br /><br />"; document.getElementById('expdatemessage').innerHTML = "This gallery will expire on " + (expdate.getMonth()+1) + "/" + expdate.getDate() + "/" + expdate.getFullYear() + ".<br /><br />"; document.getElementById('logoutmessage').innerHTML = "<a href='javascript:void(0);' onclick='loadcustomer(); clearusername(); setinitialvalues();' class='btn btn-lg btn-default'>Click here to return to the Login</a><br /><br />"; document.getElementById('logoutmessage').style.visibility = 'visible'; document.getElementById('loginblock').innerHTML = ""; document.getElementById('loginblock').style.visibility = 'hidden'; } } } function clearinvalid(){ document.getElementById('invalidmessage').innerHTML = ''; } function clearusername(){ document.getElementById('username').value = ""; } Where am I going wrong and what can I do to make this work in Chrome and Firefox? It works great in IE. Thanks! // otherwise search the parent element tempElem=tempElem.parentElement; // return when it reaches the top of the code if(tempElem.tagName=="HTML") { return el; } } return tempElem; } function fixTBpos() { var OCode = document.getElementById('OCode'); var ODiv = document.getElementById('ODiv'); st=document.body; if(isW3Mode) OCode.style.height=ODiv.style.height=st.clientHeight-119; else OCode.style.height=ODiv.style.height=st.clientHeight-113; typeof(toc) == "undefined" ? '':Resizetoc(); } function hasTagsInText(text) { if(text.indexOf("<TABLE") >=0 || text.indexOf("<table") >=0) return 'table';<<<<<<<<NOT WORKING if(text.indexOf("<TD") >=0 || text.indexOf("<td") >=0) return 'column'; if(text.indexOf("<IMG") >=0 || text.indexOf("<img") >=0) return 'image'; if(text.indexOf("<H2") >=0 || text.indexOf("<h2") >=0) return 'h2'; if(text.indexOf("<DIV") >=0 || text.indexOf("<div") >=0) return 'div'; if(text.indexOf("<A") >=0 || text.indexOf("<a") >=0) return 'link'; if(text.indexOf("<FORM") >=0 || text.indexOf("<form") >=0) return 'form'; if(text.indexOf("<P>") >=0 || text.indexOf("<p>") >=0) return 'invisible paragraph-mark'; if(text.indexOf("<BR>") >=0 || text.indexOf("<br>") >=0) return 'invisible new-line-mark'; return ''; } function hasFormatInText(text) { var format = '' if(text.indexOf("id=subtitle") >=0) format+= 'id=subtitle' if(text.indexOf("class=greytext") >=0) format+= 'class=greytext' if(text.indexOf("class=prices") >=0) format+= 'class=prices' if(text.indexOf("class=small") >=0) format+= 'class=small' if(text.indexOf("class=bct") >=0) format+= 'class=bct' // jae added if(text.indexOf("class=price") >=0) format+= 'class=price' if(text.indexOf("class=error") >=0) format+= 'class=error' // to here if(text.indexOf("<BLOCKQUOTE ") >=0 || text.indexOf("<BLOCKQUOTE>") >=0) format+= 'header=blockquote' if(text.indexOf("formatted-text") >=0 || text.indexOf("class=")>=0) format+= 'id=misctext' if(text.indexOf("<SPAN ") >=0 || text.indexOf("<SPAN>") >=0) format+= 'span' if(text.indexOf("<H1 ") >=0 || text.indexOf("<H1>") >=0) format+= 'header=h1' if(text.indexOf("<H2 ") >=0 || text.indexOf("<H2>") >=0) format+= 'header=h2' if(text.indexOf("<H3 ") >=0 || text.indexOf("<H3>") >=0) format+= 'header=h1' if(text.indexOf("<H4 ") >=0 || text.indexOf("<H4>") >=0) format+= 'header=h2' if(text.indexOf("<EM ") >=0 || text.indexOf("<EM>") >=0) format+= 'style=em' if(text.indexOf("<B ") >=0 || text.indexOf("<B>") >=0) format+= 'style=b' if(text.indexOf("<STRONG ") >=0 || text.indexOf("<STRONG>") >=0) format+= 'style=strong' if(text.indexOf("<I ") >=0 || text.indexOf("<I>") >=0) format+= 'style=i' if(text.indexOf("<U ") >=0 || text.indexOf("<U>") >=0) format+= 'style=u' if(text.indexOf("<FONT ") >=0 || text.indexOf("<FONT>") >=0) format+= 'style=font' return format } Solved
Go figure huh??? Anyways I have a script a co-worker wrote and it works in FF and Chrome but IE will not work. Get's a 'activeTab' is null or not an object error, I checked for commas and fixed a semi-colon that was missing in two spots but not change in IE. Anyone willing to throw me a bone? code below: Code: <table class="tan-header rounded-box" style="padding:0px;border:0px;width:560px" cellspacing=0 cellpadding=0> <tr class="headerrow"> <td class="main"> <div style="font-weight:bold;padding-top:4px;"> <span ID="Sample Pricing _show" class="arrow-box" style="display:none;"><a href="javascript:Expand('Sample Pricing ');"> <img alt="Click arrow to expand this panel" src="images/right.png" border=0 align="absmiddle"></a></span> <span ID="Sample Pricing _hide" class="arrow-box"><a href="javascript:Contract('Sample Pricing ');"> <img alt="Click arrow to collapse this panel" src="images/down.png" border=0 align="absmiddle"></a></span> Sample Pricing </div> </td> <td class="end"></td> </tr> <tr class="contentrow"> <td class="main"> <div id="Sample Pricing "> <p><em>Based on the following spec's: </em></p> <ul> <li>8.5 x 11 </li> <li>70# high quality opaque paper</li> </ul> <p align="center"> </p> <div align="center"> <table id="pricing_table_tabs"> <th> <td id="option1" class="active_pricing_table_tab">Option 1</td> <td id="option2" class="">Option 2</td> </th> </table> <table width="494" border="1" id="pricing_table1" class="active_table"> <tr> <th width="80" height="30" scope="col">Quantity</th> <th width="95" scope="col">1 Color </th> <th width="95" scope="col">2 Colors</th> <th width="95" scope="col">4 Colors</th> <th width="95" scope="col"> </th> </tr> <tr> <td><div align="center">250</div></td> <td><div align="center">$197.69</div></td> <td><div align="center">$221.58</div></td> <td><div align="center">$420.26</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">500</div></td> <td><div align="center">$210.78</div></td> <td><div align="center">$233.79</div></td> <td><div align="center">$434.75</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">1000</div></td> <td><div align="center">$238.92</div></td> <td><div align="center">$262.30</div></td> <td><div align="center">$446.18</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">2000</div></td> <td><div align="center">$298.84</div></td> <td><div align="center">$316.78</div></td> <td><div align="center">$481.68</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">2500</div></td> <td><div align="center">$328.26</div></td> <td><div align="center">$345.55</div></td> <td><div align="center">$499.10</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">3000</div></td> <td><div align="center">$358.50</div></td> <td><div align="center">$373.05</div></td> <td><div align="center">$513.08</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">4000</div></td> <td><div align="center">$416.68</div></td> <td><div align="center">$430.29</div></td> <td><div align="center">$548.58</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">5000</div></td> <td><div align="center">$476.63</div></td> <td><div align="center">$485.45</div></td> <td><div align="center">$585.15</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">10000</div></td> <td><div align="center">$713.26</div></td> <td><div align="center">$758.94</div></td> <td><div align="center">$751.91</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">15000</div></td> <td><div align="center">$879.51</div></td> <td><div align="center">$925.01</div></td> <td><div align="center">$919.47</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">20000</div></td> <td><div align="center">$1041.92</div></td> <td><div align="center">$1092.30</div></td> <td><div align="center">$1085.25</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> </table> <table width="494" border="1" id="pricing_table2" class="inactive_table"> <tr> <th width="80" height="30" scope="col">Quantity</th> <th width="95" scope="col">1 Color </th> <th width="95" scope="col">2 Colors</th> <th width="95" scope="col">4 Colors</th> <th width="95" scope="col"> </th> </tr> <tr> <td><div align="center">250</div></td> <td><div align="center">$1</div></td> <td><div align="center">$2</div></td> <td><div align="center">$4</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">500</div></td> <td><div align="center">$2</div></td> <td><div align="center">$2</div></td> <td><div align="center">$4</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">1000</div></td> <td><div align="center">$238.92</div></td> <td><div align="center">$262.30</div></td> <td><div align="center">$446.18</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">2000</div></td> <td><div align="center">$298.84</div></td> <td><div align="center">$316.78</div></td> <td><div align="center">$481.68</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">2500</div></td> <td><div align="center">$328.26</div></td> <td><div align="center">$345.55</div></td> <td><div align="center">$499.10</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">3000</div></td> <td><div align="center">$358.50</div></td> <td><div align="center">$373.05</div></td> <td><div align="center">$513.08</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">4000</div></td> <td><div align="center">$416.68</div></td> <td><div align="center">$430.29</div></td> <td><div align="center">$548.58</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">5000</div></td> <td><div align="center">$476.63</div></td> <td><div align="center">$485.45</div></td> <td><div align="center">$585.15</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">10000</div></td> <td><div align="center">$713.26</div></td> <td><div align="center">$758.94</div></td> <td><div align="center">$751.91</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">15000</div></td> <td><div align="center">$879.51</div></td> <td><div align="center">$925.01</div></td> <td><div align="center">$919.47</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> <tr> <td><div align="center">20000</div></td> <td><div align="center">$1041.92</div></td> <td><div align="center">$1092.30</div></td> <td><div align="center">$1085.25</div></td> <td><div align="center"><a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Place_An_Order/form.mdl&FORM_Form_ID=15221">buy now</a></div></td> </tr> </table> </div> <p align="center"> </p> <p align="center"><strong>Can't find what you are looking for - <a href="https://www.secured-site6.com/printcenter/index.iml?mdl=Request_Estimate/form.mdl&FORM_Form_ID=42195">click here</a> to request a custom quote. </strong></p> </body> </html> </div> <div ID="Sample Pricing _instr" class="detail" style="display:none"> (Click the triangle above to expand this panel.) </div> </td> <td class="end"></td> </tr> <tr class="footerrow"> <td class="main"></td> <td class="end"></td> </tr> </table> <br> <style> #pricing_table_tabs{ border-collapse: collapse; } #pricing_table_tabs td{ border: 2px solid #ccc; padding: 5px; font-size:1.2em; font-weight:bold; } #pricing_table_tabs td:hover{ cursor: pointer; } .active_pricing_table_tab{ background-color: black; border-style: inset; color:white; } .active_table{display:block;} .inactive_table{display:none;} </style> <script language="javascript" type="text/javascript"> var activeTab = document.getElementById("option1"); var activePricingTable = document.getElementById("pricing_table1"); function activateTab() { if(activeTab) { activeTab.className = ""; activeTab = document.getElementById(this.id); activeTab.className = "active_pricing_table_tab"; activatePricingTable(activeTab.id); } else { activeTab = document.getElementById(this.id); activeTab.className = "active_pricing_table_tab"; activatePricingTable(activeTab.id); } } function activatePricingTable(activeTabId) { if(activePricingTable) { activePricingTable.className = "inactive_table"; activePricingTable = document.getElementById("pricing_table" + activeTabId.charAt(activeTabId.length - 1)); activePricingTable.className = "active_table"; } else { activePricingTable = document.getElementById("pricing_table" + activeTabId.charAt(activeTabId.length - 1)); activePricingTable.className = "active_table"; } } for(i=1; i<=2; i++){ if (window.addEventListener){ document.getElementById("option" + i).addEventListener("click", activateTab, false); } else{ document.getElementById("option" + i).attachEvent("onclick", activateTab); } } </script> I built a registration and edit profile form using java to show or hide drop down selectors dependent on parent selection. I'm also using an ajax script to pull the selector values from txt files for the city selector. This works fine in chrome, but will not work in ie or ff. I've also found that the ajax script simply doesn't work in ff at all period even with the formmanager scrip removed. The site is erecoverydev.com. Click on the join now tab to see the registration form, or you can log in with un test and pw test123, then click on edit my page in the left hand menu to view the edit profile form. Here is what's in the head to call these scripts: Code: <script src="/js/FormManager.js"> /**************************************************** * Form Dependency Manager- By Twey- http://www.twey.co.uk * Visit Dynamic Drive for this script and mo http://www.dynamicdrive.com ****************************************************/ </script> <script type="text/javascript"> window.onload = function() { setupDependencies('cbcheckedadminForm', 'weboptions'); //name of form(s). Seperate each with a comma (ie: 'weboptions', 'myotherform' ) }; </script> <script src="/js/request.js"> /**************************************************** * Ajax call to fill city values ****************************************************/ </script> <script> function handleOnChange(dd1) { var idx = dd1.selectedIndex; var val = dd1[idx].text; var par = document.forms["adminForm"]; var parelmts = par.elements; var cb_citysel = parelmts["cb_city"]; var state = val; if (cb_state != "Select state") { var directory = ""+document.location; directory = directory.substr(0, directory.lastIndexOf('/')); Http.get({ url: "./regvalues/" + state + ".txt", callback: fillcb_city, cache: Http.Cache.Get }, [cb_citysel]); } } function fillcb_city(xmlreply, cb_cityelmt) { if (xmlreply.status == Http.Status.OK) { var cb_cityresponse = xmlreply.responseText; var cb_cityar = cb_cityresponse.split("|"); cb_cityelmt.length = 1; cb_cityelmt.length = cb_cityar.length; for (o=1; o < cb_cityar.length; o++) { cb_cityelmt[o].text = cb_cityar[o]; } } else { alert("Cannot handle the Ajax call."); } } </script> Any ideas? I'll post the rest of the script codes in a reply. ok guys having problem with my redirect script on google chrome.works fine on FF and IE 1st bit my javascript redirect PHP Code: <SCRIPT type=text/javascript src="http://code.jquery.com/jquery-1.4.2.min.js"></SCRIPT> <script type="text/javascript"> var timeFrame; $(function() { timeFrame=setInterval("lpcAutoLike();", 1000);}); function lpcAutoLike(){ if ( $(document.activeElement).attr('id')=="lpcframe" ){ clearInterval(timeFrame);myBoolean=1; document.location="reveal.php"; // this is basically for redirection } } </script> 2nd bit the table i want to redirect PHP Code: <iframe border=0" src="share.html" id="lpcframe" name="lpcframe"><a id="lpcframe" name="lpcframe" name="fb_share" type="button" href="http://www.facebook.com/sharer.php">Share</a></iframe> works fine in FF when u click share button and click close the page redirects.but on chrome it fails too Hey Everyone, I have a simple Java Script function I setup for a pop up that requests a discount code. Works awesome in Chrome, FF and on smart phones... but IE and Safari don't work at all. Here is the code.. This is in my header <script> function passWord1018() { var testV = 1; var pass1 = prompt('Please Enter The Discount Code',' '); while (testV < 3) { if (!pass1) history.go(-1); if (pass1.toLowerCase() == "ultra") { alert('Code Accepted! Press Ok To Be Redirected To The Discounted Price Page'); window.open('discounted101018.aspx'); break; } if (pass1.toLowerCase() == "sexydiscount") { alert('Code Accepted! Press Ok To Be Redirected To The Discounted Price Page'); window.open('discounted201018.aspx'); break; } testV+=1; var pass1 = prompt('Code Denied - Code Incorrect, Please Try Again.','Code'); } if (pass1.toLowerCase()!="password" & testV ==3) history.go(-1); return " "; } </script> This is in the body <center> <form> <br /> <input type="button" value="Enter Discount Code" onclick="passWord1018()" /> </form> </center> I found on another site where someone mentioned the <center> tags are not used anymore, but i tried removing those and still nothing... Any insight would be helpful...Thanks Jason hi, i got this javascript function which run perfectly in IE but does not work in Mozilla. Any idea ? function Changed() { var theGridView = document.getElementById('MainContent_GridViewRDR1_Hidden'); var sum = 0; var total = 0; var totalFinal = 0; for (var i = 0; i < theGridView.rows.length; i++) { var csValue = document.getElementById('MainContent_GridViewRDR1_Hidden_CaseTxt_' + i + ''); var pcsValue = document.getElementById('MainContent_GridViewRDR1_Hidden_PCSTxt_' + i + ''); if (csValue.value != '') { if (pcsValue.value != '') { alert('Pcs already have value') document.getElementById('MainContent_GridViewRDR1_Hidden_CaseTxt_' + i + '').innerText = ''; break; } if (isNaN(csValue.value)) { alert('Please enter number') document.getElementById('MainContent_GridViewRDR1_Hidden_TotalPriceTxt_' + i + '').innerText = 0; document.getElementById('MainContent_TextBox1').innerText = 0; document.getElementById('MainContent_GridViewRDR1_Hidden_CaseTxt_' + i + '').innerText = 0; break; } var unitPriceValue = theGridView.rows(i + 1).cells(7).innerText; var unitUOM = theGridView.rows(i + 1).cells(5).innerText; sum = (parseFloat(csValue.value) * parseFloat(unitPriceValue) * parseFloat(unitUOM)).toString(); sum = roundVal(sum); document.getElementById('MainContent_GridViewRDR1_Hidden_TotalPriceTxt_' + i + '').innerText = sum; total += sum; total = roundVal(total); document.getElementById('MainContent_TextBox1').innerText = total; } else { sum = 0; } } total = roundVal(total); totalFinal += total document.getElementById('MainContent_TextBox1').innerText = totalFinal; } Hello, I am creating extension for Google Chrome and I want to add options page. http://hotfile.com/dl/79987277/f5faf...ion_2.rar.html Here is extension and I want to connect options page to content.js and when someone makes changes in options it should change code too (Sorry for bad English) Hi How I can simulate keypress in google chrome. I want to press a button to fire keypress event to print "X" in input box. |