JavaScript - Dual Onclick Div And Iframe Load Working In Firefox But Not Safari Or Chrome?
Hello all, my second post!
I finally got the below script working in Firefox and was really pumped about it until I realized it didn't load in Google chrome or Safari. What this script does is its a dual onclick event which makes a hidden div appear and loads an iframe within the now visible div. Here is the code, I would love any input on how to make this work in other browsers. Here is the header code: Code: <SCRIPT type="text/javascript"> <!-- var state = 'none'; function showhide(layer_ref) { if (state == 'block') { state = 'none'; } else { state = 'block'; } if (document.all) { //IS IE 4 or 5 (or 6 beta) eval( "document.all." + layer_ref + ".style.display = state"); } if (document.layers) { //IS NETSCAPE 4 or below document.layers[layer_ref].display = state; } if (document.getElementById &&!document.all) { hza = document.getElementById(layer_ref); hza.style.display = state; } } //--> </script> <SCRIPT type="text/javascript"> function loadIframe(iframeName, url) { if ( window.frames[iframeName] ) { window.frames[iframeName].location = url; return false; } else return true; } </script> Here is the code on the page where a link click shows the hidden div and loads the iframe contained. Code: <p><a href="#" onclick="showhide('div1');return loadIframe('ifrm1', 'http://www.google.com');">show/hide me</a></p> </td></tr> <div id="div1" style="display: none; position: fixed; z-index:4; width: 1010px; height: 500px; left: 5%; top: 15%; background-color: #f0f0f0; border: 1px solid #000; padding: 10px;"><iframe name="ifrm1" id="ifrm1" width="100%" height="90%" scrolling="yes" frameborder="0">Sorry, your browser doesnt support iframes.</iframe><p><a href="#" onclick="showhide('div1')">close</a></div>'; As always, any input is greatly appreciated! Similar TutorialsI am a javascript newbie. I have a radio website that runs a live stream 24/7. The live stream is loaded in to an iframe named "stream". I only ever have 2 files that show in that iframe. 1 for when the user has the stream on and another for when they turn it off. stream_on.php and stream_off.php I also have podcasts on the site and my goal is when the user clicks the .swf object to play the podcast, the live stream in the iframe changes to stream_off.php so that the 2 audios don't overlap each other. Here's the code I have so far for the .swf object. PHP Code: <object type='application/x-shockwave-flash' data='player_mp3_maxi.swf' width='50' height='20' class='blur' onclick="window.open('stream_off.php','stream')\"> <param name='movie' value='player_mp3_maxi.swf' /> <param name='bgcolor' value='#666666'>"; if ($row['location'] == "") { echo "<param name='FlashVars' value='mp3=". $site ."podcasts/". $filename ."&showslider=0&showstop=1&autoload=0&bgcolor1=330066&width=50' />"; } else { echo "<param name='FlashVars' value='mp3=http://". $row['location'] . $filename ."&showslider=0&showstop=1&autoload=0&bgcolor1=330066&width=50' />"; } </object> And the code for the iframe. It's default state is stream_on.php since on load I want the stream to start right away. I only need it to change upon clicking of any .swf object on the page. PHP Code: <iframe src='stream_on.php' id='stream' marginheight='0' width='195' height='110' frameborder='0' scrolling='no'></iframe> As you can see, I put the onclick in the object tag. Is this correct ? Is there a piece of javascript code I am missing ? Please Help. 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 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 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 have an "animated slideshow" of 29 jpeg images on a page created using Javascript. It works fine in Internet Explorer and Firefox but not Safari or Chrome. The jpeg files names are 01.jpg through to 29.jpg. Here below is the code in the header and the body. There is an error in there somewhe <html> <head> <title>My webpage</title> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> <SCRIPT language="JavaScript" type="text/JavaScript"> <!-- var speed=1333; var counter = 1; function rollPics() { document.display.src=counter+".jpg"; //Display image "counter".jpg counter ++; // Add 1 to counter if (counter>29) { // If counter is greater than 29 images then reset it counter=1 } } <!-- END --> </SCRIPT> </head> <body> <center> <table> <tr><td> <IMG NAME="display" SRC="1.jpg" onLoad="setTimeout('rollPics()',1333)"> </td></tr> </table> </center> </body> </html> Hi, I'm new to this forum so please forgive me on any errors I may have made. I am working on a simple site for the company that I work for that allows a customer to input a 5 digit code in and returns what prize they have won. I found some code on a website which done the trick but it doesn't work in Chrome and Safari. My Javascript knowledge is extremely limited but I think I've narrowed it down to the "document.implentation.createDocument" line although the few fixes I've found, I can't get to work. Here is the code I have at the moment before I applied the fixes (this works in FF and IE). Code: <script type="text/javascript"> window.onload = loadIndex; function loadIndex() { // load indexfile // most current browsers support document.implementation if (document.implementation && document.implementation.createDocument) { xmlDoc = document.implementation.createDocument("", "", null); xmlDoc.load("results.xml"); } // MSIE uses ActiveX { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.load("results.xml"); } } function searchIndex() { // search the index (duh!) if (!xmlDoc) { loadIndex(); } // get the search term from a form field with id 'searchme' var searchterm = document.getElementById("searchme").value; var allitems = xmlDoc.getElementsByTagName('item'); results = new Array; if (searchterm.length < 4) { alert("Please re-check and enter your 5 digit code"); } else { for (var i=0;i<allitems.length;i++) { // see if the XML entry matches the search term, // and (if so) store it in an array var name = allitems[i].lastChild.nodeValue; var exp = new RegExp(searchterm,"i"); if ( name.match(exp) != null) { results.push(allitems[i]); } } // send the results to another function that displays them to the user showResults(results, searchterm); } } // Write search results to a table function showResults(results, searchterm) { if (results.length > 0) { // if there are any results, write them to a table document.write('<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><link href="cno-competition.css" rel="stylesheet" type="text/css" /></head><body>'); document.write('<div id="container"><div id="logo"></div><div id="prizeContent"><img src="media/new-york.jpg" width="750" height="500" alt="New York" />'); for(var i=0; i<results.length; i++) { document.write('<h1>Congratulations</h1><p>You entered prize code <b><i>'+searchterm+'</i></b> and have won a <span style="font-weight:bold; color:#75ACC1">' + results[i].getAttribute("prize") + '</span>.</p>'); } document.write('<p>To claim your prize please contact the Complete Night Out team on 01908 544445.</p>'); document.write('</div></div></body></html>'); document.close(); } else { // else tell the user no matches were found var notfound = alert('No results found for '+searchterm+'! Please re-check and enter your 5 digit code'); } } </script> The fix I found added the below into the code but I couldn't get it to work using this. Link here. Code: var xmlhttp = new window.XMLHttpRequest(); xmlhttp.open("GET","results.xml",false); xmlhttp.send(null); xmlDoc = xmlhttp.responseXML.documentElement; Any help would be much appreciated. If you would like to see the site live please click here Thank you. Kishan I am using javascript to change the buttons on my website so that they load up a different image when hot spots on the buttons are hovered over. Everything has been working great, but this morning I tried checking out my site and for some reason the javascript wasn't working in Chrome, or on my iphone using Safari. I tried it in IE and everything still works. Any ideas on why it would stop working for those two browsers? Here is the javascript: Code: function init(){ document.getElementsByTagName('area')[0].onmouseover=function(){ document.getElementById('crocodileImg').src='Images/crocodileHover.png'; this.onmouseout=function() { document.getElementById('crocodileImg').src='Images/crocodile.png'; } } document.getElementsByTagName('area')[1].onmouseover=function(){ document.getElementById('historyImg').src='Images/historyHover.jpg'; this.onmouseout=function() { document.getElementById('historyImg').src='Images/history.jpg'; } } document.getElementsByTagName('area')[2].onmouseover=function(){ document.getElementById('applyImg').src='Images/applyHover.jpg'; this.onmouseout=function() { document.getElementById('applyImg').src='Images/apply.jpg'; } } document.getElementsByTagName('area')[3].onmouseover=function(){ document.getElementById('applyImg').src='Images/membersHover.jpg'; this.onmouseout=function() { document.getElementById('applyImg').src='Images/apply.jpg'; } } document.getElementsByTagName('area')[4].onmouseover=function(){ document.getElementById('mediaImg').src='Images/mediaHover.jpg'; this.onmouseout=function() { document.getElementById('mediaImg').src='Images/media.jpg'; } } } if(window.addEventListener){ window.addEventListener('load',init,false); } else { if(window.attachEvent){ window.attachEvent('onload',init); } } I'm not sure if seeing the html the js is referencing will help at all, but here it is just in case: Code: <div id="crocodile"> <img id="crocodileImg" src="Images/crocodile.png" usemap="#crocodileImg" border="0" width="436" height="147" alt="Home" /> <map id="crocodileImg" name="crocodileImg"> <area id="crocArea" shape="poly" coords="41,9,23,21,20,58,40,78,72,78,82,86,88,112,117,129,140,126,257,126,274,107,274,79,401,78,420,66,419,26,404,6,369,7,366,0,294,0,291,7," href="index.html" alt="Home" title="Home" /> </map> </div> <div id="history"> <img id="historyImg" src="Images/history.jpg" usemap="#historyImg" border="0" width="350" height="256" alt="Home" /> <map id="historyImg" name="historyImg"> <area id="historyArea" shape="poly" coords="18,77,18,167,48,170,79,208,124,233,174,238,228,218,257,188,266,176,280,184,306,182,338,102,331,93,271,92,254,54,226,27,196,11,169,4,137,7,109,17,82,33,65,51,52,74," href="history2.html" alt="History" title="History" /> </map> </div> <div id="apply"> <img id="applyImg" src="Images/apply.jpg" usemap="#applyImg" border="0" width="280" height="223" alt="Apply" /> <map id="applyImg" name="applyImg"> <area id="applyArea" shape="poly" coords="17,43,17,57,15,72,20,84,39,83,43,79,56,76,62,62,65,49,77,42,76,36,70,22,65,14,52,14,45,21,38,24,31,32," href="apply.html" alt="Apply" title="Apply" /> <area id="membersImg" shape="poly" coords="112,49,97,55,77,71,64,89,61,99,47,104,44,123,44,149,46,164,57,168,70,172,82,186,102,197,125,206,146,208,168,201,188,189,201,177,208,166,231,165,254,165,260,150,262,133,262,113,254,97,238,95,221,97,213,97,205,85,197,74,183,63,172,55,159,51,145,48,134,47,"href="members.html" alt="Members" title="Members" /> </map> </div> <div id="media"> <img id="mediaImg" src="Images/media.jpg" usemap="#mediaImg" border="0" width="182" height="149" alt="Media" /> <map id="mediaImg" name="mediaImg"> <area id="mediaArea" shape="poly" coords="0,102,16,103,26,117,44,129,67,133,92,128,108,115,118,102,165,102,170,88,173,65,172,52,161,49,141,49,132,42,121,42,110,30,96,22,76,16,60,14,44,18,30,29,19,36,13,48,0,51," href="media.html" alt="Media" title="Media" /> </map> </div> Thank you for any replies. Firefox works a dream, but in IE, Google Chrome, Safari and Avant javascript does not run at all. Looking at the code it may be the body 'onload' that is not firing? Has anyone got any advise on this on how I might be able to fix it. the javascript Code: /* Script by FPMC at http://jsarchive.8m.com Submitted to JavaScript Kit (http://javascriptkit.com) For this and 400+ free scripts, visit http://javascriptkit.com */ src = ['../images/Intro_01.png', '../images/Intro_02.png', '../images/Intro_03.png', '../images/Intro_04.png', '../images/Intro_05.png', '../images/Intro_06.png']; //set image paths // url = ['http://freewarejava.com', 'http://javascriptkit.com', 'http://dynamicdrive.com', 'http://www.geocities.com']; //set corresponding urls duration = 3; //set duration for each image //Please do not edit below ads=[]; ct=0; function switchAd() { var n=(ct+1)%src.length; if (ads[n] && (ads[n].complete || ads[n].complete==null)) { document['Intro_Image'].src = ads[ct=n].src; } ads[n=(ct+1)%src.length] = new Image; ads[n].src = src[n]; setTimeout('switchAd()',duration*1000); } the body tag Code: <body onload="switchAd(this);"> the img tag Code: <img id="Intro_Image" src="images/Intro_01.png" alt="slideshow" style="width: 230px; border: 0;"> Hello....I have written a PHP script for a secure client login system and it is working on Firefox and Chrome. But it doesn't work on Safari and IE. I have noticed that some of the javascript functions do not work at all while a few of them work. Can somebody please take a look and let me know what could be wrong? I am pasting the part of my code that does't work up he <script type="text/javascript"> function newdir(i) { alert('Newdir!'); var newdir=prompt("Please enter the name of the folder"); if (newdir!=null && newdir!="") { document.getElementById('newdir').value= newdir; document.getElementById('folder').value= i; document.getElementById('download').value = ''; document.myform.submit(); } } </script> <?php $dir = '../Users/gcreddy/' echo '<tr><td></td><td></td><td><a href=# onMouseOver="this.src=\'images/delete_s.png\';" onMouseOut="this.src=\'images/delete.png\';" onClick="setdir(''.$dir.'&apos"><img src="images/delete.png" name="Delete"></a></td><td></td><td></td><td><a href=# onMouseOver="document.newdirimg.src=\'images/newdir.png\';" onMouseOut="document.newdirimg.src=\'images/newdir_s.png\';" onClick="newdir(''.$dir.'&apos"><img src="images/newdir_s.png" name="newdirimg"></a></td></tr>'; echo '<tr><td></td><td></td><td>Upload file:<input type="file" style="background-color:gray;" name="datafile" size="40"></td><td><a href=# onMouseOver="document.load.src=\'images/upload_s.png\';" onMouseOut="document.load.src=\'images/upload.png\';" onClick="upload(\''.$dir.'\')"><img src="images/upload.png" name="load"></a></td><td><input type="hidden" name="login" value="'.$user.'"><input type="hidden" name="password" value="'.$password.'"><input type="hidden" name="number" value="'.$indexCount.'"><input type="hidden" id="folder" name="folder" value=""><input type="hidden" id="newdir" name="newdir" value=""></td><td><input type="hidden" id="download" name="download" value=""></td><input type="hidden" id="Delete" name="Delete" value=""></tr></TABLE></form>'; ?> When I click on the create folder button (newdir.png), I don't see the alert message that I gave for debugging. I have the SAME problem with 2 more buttons on the same page. I would be glad if somebody could let me know what the problem / solution is. Regards, G.C.Reddy 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()"/> Hello I have created awebpage here with an onmouseover slideshow, adapted from the Cut & paste Onmouseover Slideshow from Javascript kit This works in IE8 but not in Firefox or Chrome. I appreciate this may have been previously solved but I cannot find it in the threads. 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! Hi, I have a login script which is working in IE but not firefox or safari. I was hopoing someone might be able to point me in the right direction as i'm at a loss as to why it isn't working My login form looks like this Code: <?php session_start(); include_once("inc.php"); $wlog='not'; $msm_error=''; if (isset($_GET['wlog'])) { $wlog=$_GET['wlog']; if($wlog =='out' or $wlog =='not') { global $HTTP_SESSION_VARS; unset($HTTP_SESSION_VARS['client']); } if($wlog =='not') { $msm_error='<h1 style="color:#CC0000">Username or Password is incorrect</h1>'; } }else{ $wlog=$_GET['wlog']; } $cms=check_login_status(); $show_cat=0; $show_cat_sub=0; $brand=0; $p_size=0; $color=0; $r_price=0; $status=0; ?> function client_login_signup_form($wlog,$msm_error) { if($wlog =='out') { global $HTTP_SESSION_VARS; unset($HTTP_SESSION_VARS['client']); } ?> <form name='Formlogin' id='Formlogin' method='post' action='check_user.php' onSubmit='return clientvalidate();'> <input type='hidden' name='wlog' id='wlog' value='<?php echo $wlog; ?>'/> <div id='logmsm'><?php echo $msm_error; ?></div> <h1>Existing Customer - Login</h1> <p style='color:#fdca00'>Please enter your email address and password</p> <table width='100%' border='0' cellspacing='2' cellpadding='2'> <tr> <td width="20%" align='left'><p>Email Address: </p></td> <td width="80%" ><input name='e_mail' type='text' class="input1" id='e_mail' /></td> </tr> <tr> <td align='left'><p>Password: </p></td> <td><input name='pass' type='password' class='input1' id='pass' /></td> </tr> <tr> <td> </td> <td><input name='submit' type='submit' value='Submit' /></td> </tr> <tr> <td colspan="2"><p style="margin-top:5px; font-size:10px"><a href="forgotten_password.php">Forgot your password ?</a></p></td> </tr> </table> </form> <?php } My Javascript validation looks like this Code: function clientvalidate() { //alert('user') if (document.Formlogin.e_mail.value=="") { alert("Please fill the E-mail.") document.Formlogin.e_mail.focus() return false }else{ var user=document.Formlogin.e_mail.value; } if (document.Formlogin.pass.value=="") { alert("Please fill the password.") document.Formlogin.pass.focus() return false }else{ var str=document.Formlogin.pass.value var v2=replacewithreg(str) if(v2==false) { document.Formlogin.pass.focus(); return false; }else{ var pass=document.Formlogin.pass.value; } } var wlog=document.Formlogin.wlog.value; url='ajax_check_client_login.php?user=' url =url+user url += '&'; url += 'pass='; url =url+pass; url += '&'; url += 'wlog='; url =url+wlog; //alert(url) javascript:void(0); new Ajax.Updater('', url); //updateaccountlink(); return true } Since I like to minimize on graphics to keep bandwidth low, I have been using a script to simulate buttons. When you mouseover, you get some color changes which revert back when you move the mouse off. Simple, right? The problem is that firefox totally ignores the script. Even worse, safari changes on mouseover, but doesn't revert on mouseout. I have this in the heading: Code: <script LANGUAGE="JavaScript"> function ColorBlock(oRegion,sLinkID) { if (document.readyState != "complete") return; window.event.cancelBubble = true; oRegion.className = "MenuSelected"; oRegion.style.cursor="hand"; sLinkID.style.color = "black"; } function UncolorBlock(oRegion,sLinkID) { if (document.readyState != "complete") return; window.event.cancelBubble = true; var oToEl = window.event.toElement; if ((oToEl && !oRegion.contains(oToEl))||!oToEl) { sLinkID.style.color = "white"; oRegion.className = "MenuUnSelected"; } } </script> And this is in the body. Code: <table class=MenuTable> <tr><td OnMouseover="ColorBlock(this, Link4);" OnMouseout="UncolorBlock(this, Link4);" CLASS="MenuUnSelected" nowrap> <a STYLE="color:white" ID="Link4" OnMouseover="this.style.textDecorationNone=true;" href="javascript:createWindow('edu.htm','edu','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=825,height=725')"> <div style="width:144; cursor=hand; font-weight:bold;"> Education </a></div></td> </tr> </table> I have a bunch of these "buttons" ... firefox ignoring the code is annoying but safari only using half the code makes it look really bad. Anyone have any ideas? I've done a lot of work over time on the site, there are just a few bugs that have been avoiding me and I am trying to hunt them all down and kill them. The page is at www.adam-k-watts.com 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 have this script and it is performing the calculations to provide an instant price quote script fine in IE and also making only certain boxes editable when a certain radio button is clicked. However in Firefox or Safari it isn't working. Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> td.calchead{ width:75px; background:none; border-top:thin solid black; text-align:right; } td.calc{ width:75px; background:none; border:thin solid black; text-align:right; } td.products{ float:right; text-align:right; border:1px solid black; } td.inputs{ width:200px; float:right; text-align:right; } p.products{ text-align:left; font-family:Georgia, "Times New Roman", Times, serif, 14px; } p.inputs{ text-align:left; font-family:Georgia, "Times New Roman", Times, serif, 14px; } input.inputs{ width:30px; background-color:CCCCCC; } p.calculate{ text-align:left; font-family:Georgia, "Times New Roman", Times, serif, 14px; } </style> <?php $header = $_POST['header']; $productid = $_POST['group1']; $width = $_POST['width']; $height = $_POST['height']; $openings = $_POST['openings']; $clearpanel = $_POST['clearpanel']; $resident = $_POST['resident']; $color = $_POST['color']; $motor = $_POST['motor']; $priceperheader=.5833; //error checking, ensures all variables are numeric between calculatable values 0 and 999 if($width>=0 && $width<=999 && $height>=0 && $height<=999 && $openings>=0 && $openings<=999 && $clearpanel>=0 && $clearpanel<=999) { $width2=$width+6; $height2=$height+6; if($productid == 'Roll-down Shutters') { $height2=$height2+4; } $wh=$width2*$height2; if($header=='yes') { $he=$openings*$width; $he=$he*$priceperheader; } else { $he=0; } if($resident=='yes') { $tax=1.085; } else { $tax=1; } if($motor=='2') { $motor=488*$openings; } else { $motor=0; } //$cl=$clearpanel*$priceperclearpanel; //echo(' ' + $wh + ' ' + $he + ' ' + $cl + ' '); //divide sq ft by 144 to get sq inches ////.050 alum =$4.94 per sq ft ////24 gauge steel =$3.72 per sq ft ////change Protexan to Lexan =9.94 sq ft ////roll downs = $24.99 per sq ft motor = $488. ////bahama impact = 25.99 sq ft no impact 21 per sq ft ////colonial impact = 25.99 and non = 21 sq ft ////Hurricane Fabric $6.38 per sq ft //All prices are self install only installation is extra and highly reccommended ////F track = $1.79 per ft ////H track = $2.29 per ft ////Texas residents add 8.25 percent sales tax //Standard Clamshell<input type='radio' name='group1' value='Standard Clamshell' onFocus="enable5()"><br /> //Impact Clamshell<input type='radio' name='group1' value='Impact Clamshell' onFocus="enable5()"><br /> //.063 Aluminum Panels<input type='radio' name='group1' value='.063 Aluminum Panels' onFocus="enable1()"><br /> //Accordian Shutters<input type='radio' name='group1' value='Accordian Shutters' onFocus="enable4()" /><br /> function sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2) { $wh=$wh*$priceperopening; $subtotal=$wh+$he; $subtotal=$subtotal+$motor; $total=$subtotal*$tax; $tax=$total-$subtotal; echo("<table><tr ><td>Product</td><td>Measured Opening</td><td>Finished Opening</td></tr> <tr><td >" . $productid . "</td><td align'right'>" . $width . " x " . $height . "</td><td align'right'>" . $width2 . " x " . $height2 . "</td></tr></table> <table><tr><td></td><td class='calchead'>Shutter</td><td class='calchead'>Header</td><td class='calchead'>Motor</td><td class='calchead'>Tax</td><td class='calchead'>Total</td></tr> <tr><td>$</td><td class='calc'>". money_format('%.2n',$wh) . "</td><td width='30' class='calc'>". money_format('%.2n',$he) . "</td><td width='30' class='calc'>" . money_format('%.2n',$motor) . "</td><td width='30' class='calc'>" . money_format('%.2n',$tax) . "</td><td align='right' class='calc'>$" . money_format('%.2n',$total) . "</td></tr></table>"); } if($productid == '.050 Aluminum Panels') { $priceperopening=.03431; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } if($productid == '24 gauge steel') { $priceperopening=.02583; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } if($productid == 'lexan') { $priceperopening=.0659; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } if($productid == 'Roll-down Shutters') { $priceperopening=.17354; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } if($productid == 'Impact Bahama Shutters') { $priceperopening=.18049; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } if($productid == 'Impact Colonial Shutters') { $priceperopening=.18049; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } if($productid == 'Hurricane Fabric') { $priceperopening=.04431; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } if($productid == 'Non-Impact Bahama Shutters') { $priceperopening=.14583; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } if($productid == 'Non-Impact Colonial Shutters') { $priceperopening=.14583; sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2); } } else {echo('Please make sure to enter numbers greater than zero and less than 999 in all required fields.');} $header=''; ?> <script type='text/javascript'> //white() clears backs of inputs to white and is called from eable functions function white(){ document.getElementById("header").style.background='#ffffff'; document.getElementById("width").style.background='#ffffff'; document.getElementById("height").style.background='#ffffff'; document.getElementById("openings").style.background='#ffffff'; document.getElementById("resident").style.background='#ffffff'; document.getElementById("color").style.background='#ffffff'; document.getElementById("motor").style.background='#ffffff'; } //enable1-5() enables particular requested fields specific for product type and disables unused fields. function enable1() { white(); document.getElementById("header").disabled=''; document.getElementById("width").disabled=''; document.getElementById("height").disabled=''; document.getElementById("openings").disabled=''; document.getElementById("resident").checked=''; document.getElementById("resident").disabled=''; document.getElementById("color").style.background='#CCCCCC'; document.getElementById("color").value=''; document.getElementById("color").disabled='true'; document.getElementById("motor").style.background='#CCCCCC'; document.getElementById("motor").value=''; document.getElementById("motor").disabled='true'; } function enable2() { white(); document.getElementById("header").disabled=''; document.getElementById("width").disabled=''; document.getElementById("height").disabled=''; document.getElementById("openings").disabled=''; document.getElementById("resident").checked=''; document.getElementById("resident").disabled=''; document.getElementById("color").value=''; document.getElementById("color").style.background='#CCCCCC'; document.getElementById("color").disabled='true'; document.getElementById("motor").value=''; document.getElementById("motor").style.background='#CCCCCC'; document.getElementById("motor").disabled='true'; } function enable3() { white(); document.getElementById("header").checked=''; document.getElementById("header").style.background='#CCCCCC'; document.getElementById("header").disabled='true'; document.getElementById("width").disabled=''; document.getElementById("height").disabled=''; document.getElementById("openings").disabled=''; document.getElementById("resident").disabled=''; document.getElementById("resident").checked=''; document.getElementById("color").disabled=''; document.getElementById("motor").disabled=''; } function enable4() { white(); document.getElementById("header").checked=''; document.getElementById("header").style.background='#CCCCCC'; document.getElementById("header").disabled='true'; document.getElementById("width").disabled=''; document.getElementById("height").disabled=''; document.getElementById("openings").disabled=''; document.getElementById("resident").checked=''; document.getElementById("resident").disabled=''; document.getElementById("color").disabled=''; document.getElementById("motor").style.background='#CCCCCC'; document.getElementById("motor").value=''; document.getElementById("motor").disabled='true'; } function enable5() { white(); document.getElementById("header").checked=''; document.getElementById("header").disabled='true'; document.getElementById("header").style.background='#CCCCCC'; document.getElementById("width").disabled=''; document.getElementById("height").disabled=''; document.getElementById("openings").disabled=''; document.getElementById("resident").checked=''; document.getElementById("resident").disabled=''; document.getElementById("color").value=''; document.getElementById("color").disabled='true'; document.getElementById("color").style.background='#CCCCCC'; document.getElementById("motor").value=''; document.getElementById("motor").disabled='true'; document.getElementById("motor").style.background='#CCCCCC'; } </script> <title>Estimator</title> </head> <body> <div> <table> <tr> <td><p class='products'>First, select a product</p></td> <td><p class='inputs'>Then, enter dimensions and select options (in inches) that appear in white</p></td> </tr> <tr> <td class='products'> <form width='550' name='form01' method='post' action='http://www.windowguardoftexas.com/estimator.php'> .050 Aluminum Panels<input type='radio' name='group1' value='.050 Aluminum Panels' onFocus="enable1()"><br /> 24 Gauge Steel<input type='radio' name='group1' value='24 gauge steel' onFocus="enable1()"><br /> Lexan<input type='radio' name='group1' value='lexan' onFocus="enable2()"><br /> Roll-down Shutters<input type='radio' name='group1' value='Roll-down Shutters' onFocus="enable3()"><br /> Impact Bahama Shutters<input type='radio' name='group1' value='Impact Bahama Shutters' onFocus="enable4()"><br /> Impact Colonial Shutters<input type='radio' name='group1' value='Impact Colonial Shutters' onFocus="enable4()"><br /> Hurricane Fabric<input type='radio' name='group1' value='Hurricane Fabric' onFocus="enable5()"><br /> Non-Impact Bahama Shutters<input type='radio' name='group1' value='Non-Impact Bahama Shutters' onFocus="enable4()"><br /> Non-Impact Colonial<input type='radio' name='group1' value='Non-Impact Colonial Shutters' onFocus="enable4()"><br /> </td> <td class='inputs'> Add Header and F-track to openings: <input type='checkbox' name='header' class='inputs' value='yes' disabled="disabled"/><br /> Width: <input type='text' class='inputs' name='width' value='' maxlength='3'disabled='disabled' /><br /> Height: <input type='text' class='inputs' name='height' value='' maxlength='3' disabled='disabled' /><br /> Openings: <input type='text' class='inputs' name='openings' value='' maxlength='3' disabled='disabled' /><br /> Texas Resident <input type='checkbox' name='resident' class='inputs' value='yes' disabled="disabled"/><br /> Color: <select name="color" id='color' class='inputs' disabled='disabled'><br /> <option value="0" >--Select Color--</option> <option value="1" >White</option> <option value="2">Bronze</option> <option value="3">Ivory</option> <option value="3">Beige</option> </select> <br /> Motor: <select name="motor" class='inputs' disabled="disabled"><br /> <option value="0">--Select Motor--</option> <option value="1">None</option> <option value="2" >Standard</option> </select> <br /><br /> <p class='calculate'>Finally, press calculate</p> <input type='reset' name='Submit2' value='Reset'> <input type='submit' name='Submit' value='Calculate'> </td> </form> </tr> <tr><td>All prices are self install only, installation</td><td>is extra and highly reccommended</td></tr> </table> </div> </body> </html> How do I get this to work in Firefox and Safari? Why would it work in IE but not the others? Hi, i have the following html page <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> </head> <body> <input type="text" id="input1" /><br /> <iframe id="textEditor" name="textEditor"> </iframe> <script type="text/javascript"> $(document).ready( function() { textEditor.document.designMode = "on"; textEditor.document.open(); textEditor.document.write('<head><style type="text/css">body{ font-family:arial; font-size:13px;}</style><body>Hi User<br /><br /><span style="font-style:italic;">### Write your message here ###</span><br /><br />Thanks,<br /></body></head>'); document.getElementById("textEditor").contentWindow.addEventListener('focus', OnFocus, true); $("#input1").focus(); } ); function OnFocus() { textEditor.document.body.innerHTML = textEditor.document.body.innerHTML.replace('<span style="font-style:italic;">### Write your message here ###</span>', ""); document.getElementById("textEditor").contentWindow.focus() } </script> </body> </html> Now press on the tab key when the page loads (You should see focus on the textbox field) and you can see that the iframe text editor (WYSIWYG) has no focus... On firefox it works... How can i give it focus on chrome? My page is working as I want it to in firefox and IE. well almost fully in IE... Anyways at the top of my page I am using an fx.slide that does not work at all in safari or chrome and was wondering if anyone here could shed some light as to why? here is the page in question Any help would be great. Thanks so much. 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 Hello all, I'm back with more silly newbie questions. I'm building a website that includes 3 javascript codes: 1. Onmouseover image switch for the nav bar. 2. On a specific page, onmouseover display of hidden divs. 3. Particletree's Dynamic Resolution Dependent Layout script (http://particletree.com/features/dyn...ndent-layouts/) All three scripts work fine in firefox, but the 2nd script doesn't work in safari and chrome, and the 3rd one doesn't work in safari, chrome and IE(8). Since the 1st one works fine in all browsers, I'm guessing this isn't a problem with my javascript link or anything like that. The website is: www.sheket.co.il/index4.html The specific page that runs the 2nd code is: www.sheket.co.il/services.html My javascript is: http://www.sheket.co.il/javascript.js And my default stylesheet is: http://www.sheket.co.il/style.css (I apologize for possible jibrish- the website is in Hebrew...) Any help with these two problems would be greatly appreciated! |