JavaScript - Need Help With Two Javascripts Conflicting In Firefox And Safari!
Can someone help me figure out why these two scripts conflict in Firefox and Safari? They work fine in Internet Explorer, and they work fine in ALL browsers when they don't have to work together on the same page. When they both need to work on the same page, it's the div/column resize script that is acting up in Safari and Firefox (again, it works fine in IE). What's really strange is that when I click on my firebug icon (in the lower righthand corner) in Firefox the divs/columns resize like they should and everything looks fine. It's almost as if it's not resizing in real time like it should be, and something about me clicking that icon is making it refresh or update or something. Any help given with this matter would be greatly appreciated!
Resize two Divs (columns) to be the same height: Code: // Replace 'center' 'right' and 'left' with the ID names of the columns you want to balance. // The last one is there to show how you can add more columns. Just delete the ones you're not using. var divs = new Array('col1, 'col2'); // Initialize Scripts - is this a browser that understands DOM? function scriptInit() { if (!document.getElementById) { return; } } // Set up Event Listener function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r; } else { elm['on' + evType] = fn; } } // Start Column Script function setTall() { if (document.getElementById) { var maxHeight = 0; for (var i = 0; i < divs.length; i++) { if (document.getElementById(divs[i]) != null) { var div = document.getElementById(divs[i]); div.style.height = null; if (div.offsetHeight > maxHeight) maxHeight = div.offsetHeight; } } for (var i = 0; i < divs.length; i++) { if (document.getElementById(divs[i]) != null) { var div = document.getElementById(divs[i]); div.style.height = maxHeight + 'px'; if (div.offsetHeight > maxHeight) { div.style.height = (maxHeight - (div.offsetHeight - maxHeight)) + 'px'; } } } } } // Assign one of the columns to the TextResizeDetector. function initTall() { if (document.getElementById) { for (var i = 0; i < divs.length; i++) { if (document.getElementById(divs[i]) != null) { TextResizeDetector.TARGET_ELEMENT_ID = divs[i]; break; } } setTall(); } } // Fire Events addEvent(window, 'load', initTall, false); addEvent(window, 'resize', setTall, false); /* Detects changes to font sizes when user changes browser settings Fires a custom event with the following data: iBase : base font size iDelta : difference in pixels from previous setting iSize : size in pixel of text author Lawrence Carvalho carvalho@uk.yahoo-inc.com */ // @constructor TextResizeDetector = function() { var el = null; var iIntervalDelay = 200; var iInterval = null; var iCurrSize = -1; var iBase = -1; var aListeners = []; var createControlElement = function() { el = document.createElement('span'); el.id='textResizeControl'; el.innerHTML=' '; el.style.position="absolute"; el.style.left="-9999px"; var elC = document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID); // insert before firstChild if (elC) elC.insertBefore(el,elC.firstChild); iBase = iCurrSize = TextResizeDetector.getSize(); }; function _stopDetector() { window.clearInterval(iInterval); iInterval=null; }; function _startDetector() { if (!iInterval) { iInterval = window.setInterval('TextResizeDetector.detect()',iIntervalDelay); } }; function _detect() { var iNewSize = TextResizeDetector.getSize(); if(iNewSize!== iCurrSize) { for (var i=0;i <aListeners.length;i++) { aListnr = aListeners[i]; var oArgs = { iBase: iBase,iDelta:((iCurrSize!=-1) ? iNewSize - iCurrSize + 'px' : "0px"),iSize:iCurrSize = iNewSize}; if (!aListnr.obj) { aListnr.fn('textSizeChanged',[oArgs]); } else { aListnr.fn.apply(aListnr.obj,['textSizeChanged',[oArgs]]); } } } return iCurrSize; }; var onAvailable = function() { if (!TextResizeDetector.onAvailableCount_i ) { TextResizeDetector.onAvailableCount_i =0; } if (document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID)) { TextResizeDetector.init(); if (TextResizeDetector.USER_INIT_FUNC){ TextResizeDetector.USER_INIT_FUNC(); } TextResizeDetector.onAvailableCount_i = null; } else { if (TextResizeDetector.onAvailableCount_i<600) { TextResizeDetector.onAvailableCount_i++; setTimeout(onAvailable,200) } } }; setTimeout(onAvailable,500); return { /* * Initializes the detector * * @param {String} sId The id of the element in which to create the control element */ init: function() { createControlElement(); _startDetector(); }, /** * Adds listeners to the ontextsizechange event. * Returns the base font size * */ addEventListener:function(fn,obj,bScope) { aListeners[aListeners.length] = { fn: fn, obj: obj } return iBase; }, /** * performs the detection and fires textSizeChanged event * @return the current font size * @type {integer} */ detect:function() { return _detect(); }, /** * Returns the height of the control element * * @return the current height of control element * @type {integer} */ getSize:function() { var iSize; return el.offsetHeight; }, /** * Stops the detector */ stopDetector:function() { return _stopDetector(); }, /* * Starts the detector */ startDetector:function() { return _startDetector(); } } }(); /*** end TextResizeDetector */ TextResizeDetector.TARGET_ELEMENT_ID = 'doc'; TextResizeDetector.USER_INIT_FUNC = function() { var iBase = TextResizeDetector.addEventListener(setTall, null); }; Click link to show hidden text: Code: function expand(ele) { if (document.getElementById('answer'+ele).style.display == '') document.getElementById('answer'+ele).style.display='none'; else document.getElementById('answer'+ele).style.display=''; for (i=0;i <= 75;i++) { if (document.getElementById('answer'+i) != null && i != ele) document.getElementById('answer'+i).style.display='none'; } } function collapse(ele) { document.getElementById('answer'+ele).style.display='none'; } Similar TutorialsHey, I've been trying to make two javascript files kiss and make up in my web site code. I tried the "noconflict" function, but either I did it wrong, or it didn't work out. Here is the page with the conflict. Help? Hey! I'm working on a website that has the bubble navigation jquery script in it, but every time I combine it with another jquery script, it kind of goes bonkers. Right now, I'm trying to combine it with this circular image slider, here are the tutorials from the two scripts I'm using: http://tympanus.net/codrops/2010/04/...n-with-jquery/ http://www.baijs.nl/tinycircleslider/ And here's my script so far: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Tiny Carousel: A lightweight jQuery plugin</title> <link rel="stylesheet" href="css/website.css" type="text/css" media="screen"/> <!--[if lte IE 6]> <style type="text/css"> /* Internet Explorer 6 PNG transparency fix */ #rotatescroll .overlay { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="example/images/bg-rotatescroll.png", sizingmethod='scale'); } #rotatescroll .thumb { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="example/images/bg-thumb.png", sizingmethod='scale'); } </style> <![endif]--> <script type="text/javascript" src="example/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="example/js/jquery.tinycircleslider.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#rotatescroll').tinycircleslider({ interval: true, snaptodots: true }); }); </script> <title>Awesome Bubble Navigation with jQuery</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta name="description" content="Awesome Bubble Navigation with jQuery" /> <meta name="keywords" content="jquery, circular menu, navigation, round, bubble"/> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/> <style> *{ margin:0; padding:0; } body{ font-family:Arial; background:#fff url(images/bg_scoot1.png) no-repeat top left; } .title{ width:548px; height:119px; position:absolute; top:300px; left:250px; background:transparent url(title.png) no-repeat top left; } a.back{ background:transparent url(back.png) no-repeat top left; position:fixed; width:150px; height:27px; outline:none; bottom:0px; left:0px; } #content{ margin:0 auto; } </style> </head> <body> <div id="rotatescroll"> <div class="viewport"> <ul class="overview"> <li><a href="http://www.baijs.nl"><img src="example/images/hdr3.jpg" /></a></li> <li><a href="http://www.baijs.nl"><img src="example/images/hdr2.jpg" /></a></li> <li><a href="http://www.baijs.nl"><img src="example/images/hdr1.jpg" /></a></li> <li><a href="http://www.baijs.nl"><img src="example/images/hdr4.jpg" /></a></li> <li><a href="http://www.baijs.nl"><img src="example/images/hdr5.jpg" /></a></li> </ul> </div> <div class="dot"></div> <div class="overlay"></div> <div class="thumb"></div> </div> <div id="content"> <a class="back" href="http://tympanus.net/codrops/2010/04/29/awesome-bubble-navigation-with-jquery"></a> <div class="title"></div> <div class="navigation" id="nav"> <div class="item user"> <img src="images/bg_user.png" alt="" width="199" height="199" class="circle"/> <a href="#" class="icon"></a> <h2>User</h2> <ul> <li><a href="#">Profile</a></li> <li><a href="#">Properties</a></li> <li><a href="#">Privacy</a></li> </ul> </div> <div class="item home"> <img src="images/bg_home.png" alt="" width="199" height="199" class="circle"/> <a href="#" class="icon"></a> <h2>Home</h2> <ul> <li><a href="#">Portfolio</a></li> <li><a href="#">Services</a></li> <li><a href="#">Contact</a></li> </ul> </div> <div class="item shop"> <img src="images/bg_shop.png" alt="" width="199" height="199" class="circle"/> <a href="#" class="icon"></a> <h2>Shop</h2> <ul> <li><a href="#">Catalogue</a></li> <li><a href="#">Orders</a></li> <li><a href="#">Offers</a></li> </ul> </div> <div class="item camera"> <img src="images/bg_camera.png" alt="" width="199" height="199" class="circle"/> <a href="#" class="icon"></a> <h2>Photos</h2> <ul> <li><a href="#">Gallery</a></li> <li><a href="#">Prints</a></li> <li><a href="#">Submit</a></li> </ul> </div> <div class="item fav"> <img src="images/bg_fav.png" alt="" width="199" height="199" class="circle"/> <a href="#" class="icon"></a> <h2>Love</h2> <ul> <li><a href="#">Social</a></li> <li><a href="#">Support</a></li> <li><a href="#">Comments</a></li> </ul> </div> </div> </div> <!-- The JavaScript --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" src="jquery.easing.1.3.js"></script> <script type="text/javascript"> $(function() { $('#nav > div').hover( function () { var $this = $(this); $this.find('img').stop().animate({ 'width' :'199px', 'height' :'199px', 'top' :'-25px', 'left' :'-25px', 'opacity' :'1.0' },500,'easeOutBack',function(){ $(this).parent().find('ul').fadeIn(700); }); $this.find('a:first,h2').addClass('active'); }, function () { var $this = $(this); $this.find('ul').fadeOut(500); $this.find('img').stop().animate({ 'width' :'52px', 'height' :'52px', 'top' :'0px', 'left' :'0px', 'opacity' :'0.1' },5000,'easeOutBack'); $this.find('a:first,h2').removeClass('active'); } ); }); </script> </body> </html> Hello. When a user visits index.html on my site, they input their email address. The form redirects them to "confirmed.html", the form also writes a cookie with their email address. When the user gets to confirmed.html, I use an "if/else" statement. If there is a cookie (email address), I append ("#"+user_email) to the window location. I do this so that when the user shares with "addthis" tool, I will know who is sharing. Unfortunately addthis only shares the current page, so I want new users to the site to be redirected to index.html My code works in firefox, but not safari. In safari it just seems to redirect to index nomatter what. The user never even sees confirmed.html. Code: var user_email = unescape(document.cookie); if (document.cookie) { window.location.replace("#"+user_email); } else { window.location.replace("index.html"); } })(); </script> The website is www.saverally.com Code: function toggle(div_id) { var el = document.getElementById(div_id); if ( el.style.display == 'none' ) { el.style.display = 'block';} else {el.style.display = 'none';} } function blanket_size(popUpDivVar) { if (typeof window.innerWidth != 'undefined') { viewportheight = window.innerHeight; } else { viewportheight = document.documentElement.clientHeight; } if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) { blanket_height = viewportheight; } else { if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) { blanket_height = document.body.parentNode.clientHeight; } else { blanket_height = document.body.parentNode.scrollHeight; } } var blanket = document.getElementById('blanket'); blanket.style.height = blanket_height + 'px'; var popUpDiv = document.getElementById(popUpDivVar); popUpDiv_height=200 popUpDiv.style.top = popUpDiv_height + 'px'; } function window_pos(popUpDivVar) { if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerHeight; } else { viewportwidth = document.documentElement.clientHeight; } if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) { window_width = viewportwidth; } else { if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) { window_width = document.body.parentNode.clientWidth; } else { window_width = document.body.parentNode.scrollWidth; } } var popUpDiv = document.getElementById(popUpDivVar); window_width=window_width/2-150;//150 is half popup's width popUpDiv.style.left = window_width + 'px'; } function popup(windowname) { blanket_size(windowname); window_pos(windowname); toggle('blanket'); toggle(windowname); } I have know much about javascript, but the code above works fine in safari and firefox but not IE. it's for a popup, when you click a link it blankets the page and theres a popup window. here's other parts of supporting css/php Code: <?php if(!$_POST['submit'] == 'login'){ echo "<div id=\"blanket\" style=\"display:none;\"></div>\n"; echo "<div id=\"popUpDiv\" style=\"display:none;\">\n"; echo "<div id=\"loginform\">\n"; echo '<div id="close">'; echo "<a href=\"#\" onclick=\"popup('popUpDiv')\">\n"; echo '<img src="images/login/close.png" border="0">'; echo "</a>\n"; echo '</div>'; echo '<div class="clear"></div>'; echo "<form name=\"login\" method=\"post\" action=\"#\">\n"; echo "<div id=\"usernametext\">Username</div>\n"; echo "<input name=\"username\" type=\"text\" id=\"usernameinput\">\n"; echo '<div class="clear"></div>'; echo "<div id=\"passwordtext\">Password</div>\n"; echo "<input name=\"password\" type=\"password\" id=\"passwordinput\">\n"; echo '<div class="clear"></div>'; echo '<div id="loginsubmit"><input type="submit" name="submit" value="Submit"></div>'; echo "</form>\n"; echo "</div>\n"; echo "</div>\n"; echo "<span class=\"login_text\"><a href=\"#\" onclick=\"popup('popUpDiv')\">LOG IN</a></span>\n"; ?> Code: #blanket { background-color:#000000; opacity: 0.40; filter:alpha(opacity=40); position:absolute; z-index: 10; padding:0; top:0; right:0; left:0; bottom:0; width:100%; height:100%; margin:0 0 0 0; } #popUpDiv { position:absolute; background-color:#FFFFFF; width:280px; height:135px; z-index: 10; } any help would be VERY much appreciated. thanks 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 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 } 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 So I've started learning Javascript some days ago. Reading 'JavaScript Bible' Seventh Edition. One of the things the book repeatedly says is: use: Code: if(!document.getElementById()) return; (and others like: Code: if(!document.createTextNode()) return; ) to filter out all the browser who are in fact not supporting DOM. As I'm using Safari (and Firefox for testing purpose) the 'document.getElementById()' and therefo DOM is supported. Now, my browsers (both Safari and Firefox) get returned out of the javascript anyway. as simple as: Code: if(!document.getElementById()) return; document.write("testIt!"); the document.write doesn't get executed. Now: I found a simple solutions which seems to work.... partially: Code: if(document.getElementById() == "undefined") return; document.write("testIt!"); This seems to work for Safari, but Firefox still gets returned out of the javascript. I could just omit the if statements to make it work altogether. But that doesn't sound like the best method to me, because (so I've read) it can crash browsers and such. Now my question: Why are my browsers (or javascript for all I care) acting so strange? Is there a way to make the if(!document.getElementById()) work? or is it just a silly rule the writers of the JavaScript Bible made up? Thanks in advance for any help :) <BODY onLoad="populateYearSelect()"> <font face="Verdana"> <title>owner Calendar</title> </font> <!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --> function populateYearSelect() { d = new Date(); curr_month = d.getMonth(); document.getElementById('arrivemonth').options[curr_month + 1].selected=true; curr_year = d.getFullYear(); for(i = 0; i <= 3; i++) { document.getElementById('arriveyear').options[i] = new Option(curr_year+i,curr_year+i); } } </script> This is the function I am using and it works great in IE but all other browsers are not even loading the function at all. What must i do to make this work in other browsers? I need them to work more so in Firefox and Safari more so than Opera, Avant or Netscape. 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 I can't figure it out hoping for some help. The calendar pops up in IE but will not work in Firefox or safari. The page can be viewed at http://www.lackawanna.edu/lib-form/e...nt-request.asp 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? 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> This has me completely stumped. I have a multiple select form element in my HTML document that needs to be manipulated by two different sets of context-sensitive controls. One set of controls is marked up as follows: Code: <div id="divControls1" name="divControls1" style="display:none"> <form id="fControls1" name="fControls1"> <input type="button" id="btnAdd" name="btnAdd" value="Add" onClick="addStuff();" /> <input type="button" id="btnEdit" name="btnEdit" value="Edit" onClick="editStuff();" disabled /> <input type="button" id="btnDelete" name="btnDelete" value="Delete" onClick="deleteStuff();" disabled /> </form> </div> When I load this page into Safari (on Mac OS X) and set the style of divControls1 to "display:block," I have an enabled "Add" button, a disabled "Edit" button, and a disabled "Delete" button, just as I expected. (I monitor selections in a multiple selection element to turn the buttons on and off.) But when I load this page into Firefox (also Mac OS X), all three buttons are disabled at startup. My page runs a function called startup() when the body fires onLoad. To try to troubleshoot the problem, I wrote this line at the beginning of the startup() function: Code: function startup() { alert (document.getElementById("btnAdd").disabled); ... When I run this code in Safari, the alert returns "false" (not disabled), just as I would expect, and intended. However, the same code in Firefox (Mac OS X) returns "true" (disabled) ... but the same code in Firefox (WinXP) returns "false"! Any insight into what might be happening here? Hey all, 1) When clicking on a list in an accordion, it should change the quicktime movie playing in a main window area. It works in firefox but not in safari. The variable imgTitle holds the expected output (e.g. '../images/Intro-1.mov'). It changes the src attribute of the embed tag. This change works in Firefox where the new movie plays on click. However, when clicking the list item in safari, nothing happens. 2) There is a problem in firefox as well in that the movie overlays everything else on page, even though it should be behind the text. Positioning would be tedious given that there's many nested elements and I would have to set relative positioning to the entire page. Any reason for this behavior of embed tags? Code: $(".image_thumb ul li ul li").click(function(){ var imgTitle = $(this).find('a').attr("href"); var imgDesc = $(this).find('.block').html(); var imgDescHeight = $(".main_image").find('.block').height(); if ($(this).is(".active")) { return false; } else { console.log(imgTitle); $(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() { $(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 ); $(".main_image embed").attr({ src: imgTitle}); }); } $(".image_thumb ul li ul li").removeClass('active'); $(this).addClass('active'); return false; }) .hover(function(){ $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); }); Thanks for response. 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! Hi guys I have to scripts on my page and they work fine on their own but when i put them together one stops working ?? One is the colorbox script and the other toggles some hidden content. Any ideas why they wont work on the same page ? This is whats in my head section and the start of the body section Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="../../js_files/jquery.easing.1.3.js"></script> <script type="text/javascript" src="../../js_files/jquery.tools.min.js"></script> <!--[if lt IE9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--> <link rel="stylesheet" href="../../colorbox/colorbox.css" type="text/css" /> <script src="http://code.jquery.com/jquery-1.6.1.min.js" type="text/javascript"></script> <script src="../../colorbox/jquery.colorbox-min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ //Examples of how to assign the ColorBox event to elements $("a[rel='slides']").colorbox({transition:"none", width:"70%", height:"70%", scalePhotos:false}); }); </script> </head> <body> <script language="JavaScript" type="text/javascript"> $(function() { $("#tabs").tabs("#tabscontent section", { effect: 'fade', fadeOutSpeed: 0, fadeInSpeed: 400 }); }); </script> I'm trying to get a javascript lightbox and a background image resize script to work on the same webpage but one's causing the other to work incorrectly. If anyone can help combine the 2 into a working script it would be hugely appreciated: <!-- BG script --> <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script> <script type="text/javascript" src="supersized.2.0.js"></script> <script type="text/javascript"> $(function(){ $.fn.supersized.options = { startwidth: 640, startheight: 480, vertical_center: 1, slideshow: 0, }; $('#supersize').supersized(); }); </script> <!-- lightbox script --> <script type="text/javascript" src="imagezoom.js"></script> <script type="text/javascript" src="mootools-1.2.4-core-yc.js"></script> <link href="imagezoom.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> window.addEvent("domready", function() { initImageZoom(); }); </script> I have some kind of conflict in my Javascript he http://www.SonomaCountyFamilyLaw.com Drop down menu pops up when one scrolls over "Family Law," but rollover images do not load on other menu items as they should I am relatively new to Javascript; would much appreciate any assistance. Thank you kindly.... Here is the code in question: Code: <script type="text/javascript">function mmLoadMenus() { if (window.mm_menu_0514172011_0) return; window.mm_menu_0514172011_0 = new Menu("root",298,24,"Arial, Helvetica, sans-serif",14,"#FFFFFF","#020056","#3C3A7D","#FFFFFF","left","middle",5,0,100,-5,7,true,true,true,5,true,true); mm_menu_0514172011_0.addMenuItem("DIVORCE","location='divorce.html'"); mm_menu_0514172011_0.addMenuItem("CUSTODY","location='custody.html'"); mm_menu_0514172011_0.addMenuItem("ADOPTION/GUARDIANSHIP","location='adoption.html'"); mm_menu_0514172011_0.addMenuItem("PRIVATE JUDGING & SETTLEMENTS","location='private.html'"); mm_menu_0514172011_0.hideOnMouseOut=true; mm_menu_0514172011_0.bgColor='#FFFFFF'; mm_menu_0514172011_0.menuBorder=1; mm_menu_0514172011_0.menuLiteBgColor='#FFFFFF'; mm_menu_0514172011_0.menuBorderBgColor='#434089'; mm_menu_0514172011_0.writeMenus(); } // mmLoadMenus()var switchTo5x=false; function newImage(arg) { if (document.images) { rslt = new Image(); rslt.src = arg; return rslt; } } function changeImages() { if (document.images && (preloadFlag == true)) { for (var i=0; i<changeImages.arguments.length; i+=2) { document[changeImages.arguments[i]].src = changeImages.arguments[i+1]; } } } var preloadFlag = false; function preloadImages() { if (document.images) { menu_02_over = newImage("assets/menu_02-over.jpg"); menu_06_over = newImage("assets/menu_06-over.jpg"); menu_08_over = newImage("assets/menu_08-over.jpg"); menu_10_over = newImage("assets/menu_10-over.jpg"); menu_12_over = newImage("assets/menu_12-over.jpg"); menu_14_over = newImage("assets/menu_14-over.jpg"); preloadFlag = true; } } // --> </script> <!-- End Preload Script --> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script> <script type="text/javascript">stLight.options({publisher:'04ce05ad-19c3-4812-98d3-7e46a3d579db'});</script> <script language="JavaScript" src="mm_menu.js" type="text/javascript"></script> </head> <body onload="preloadImages();"> <script language="JavaScript1.2" type="text/javascript">mmLoadMenus();</script> Im pretty sure I have some javascript conflicts on my site. Can any one offer advice on how to correct this. Heres a link to a page where there are problems. Every time I refresh that page in IE8 it loads differently - sometimes it loads OK and others it stops loading before the end - a symptom of the js problems I believe? http://tinyurl.com/ocqsmv |