JavaScript - My Code Does Not Work In Internet Explorer But Works On All Other Major Browsers
I have a function which allows the number of buttons selected depending on the number selected from the drop down menu. Problem is that this code works in all of the major browsers except for Internet Explorer (No Suprise). For example if user chose the number 3 from the dropdown menu, then user can only select 3 buttons.
Why is it not working in Internet explorer and what can be used to make it work in Internet Explorer? Below is javascript functions: Code: function getButtons() { document.getElementById("answerA").class="answerBtnsOff"; document.getElementById("answerA").setAttribute("class","answerBtnsOff"); document.getElementById("answerA").setAttribute("className","answerBtnsOff"); document.getElementById("answerB").class="answerBtnsOff"; document.getElementById("answerB").setAttribute("class","answerBtnsOff"); document.getElementById("answerB").setAttribute("className","answerBtnsOff"); document.getElementById("answerC").class="answerBtnsOff"; document.getElementById("answerC").setAttribute("class","answerBtnsOff"); document.getElementById("answerC").setAttribute("className","answerBtnsOff"); document.getElementById("answerD").class="answerBtnsOff"; document.getElementById("answerD").setAttribute("class","answerBtnsOff"); document.getElementById("answerD").setAttribute("className","answerBtnsOff"); document.getElementById("answerE").class="answerBtnsOff"; document.getElementById("answerE").setAttribute("class","answerBtnsOff"); document.getElementById("answerE").setAttribute("className","answerBtnsOff"); currenttotal=0; } function btnclick(btn) { if(document.getElementById("numberDropId").value=="") { alert('You must first select the number of answers you require from the drop down menu'); return false; } if (btn.class=="answerBtnsOn") { btn.class="answerBtnsOff"; btn.setAttribute("class","answerBtnsOff"); btn.setAttribute("className","answerBtnsOff"); currenttotal--; return false; } if(document.getElementById("numberDropId").value==currenttotal) { alert('You are not allowed beyond the limit of the number of answers you require, deselect other button'); return false; } if (btn.class=="answerBtnsOff") { btn.class="answerBtnsOn"; btn.setAttribute("class","answerBtnsOn"); btn.setAttribute("className","answerBtnsOn"); currenttotal++; return false; } } If you html code then this is below: Code: <form id="enter" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return validateForm(this);" > <table id="middleDetails" border="1"> <tr> <td>Question:</td> <td rowspan="3"> <textarea rows="5" cols="40" name="questionText"></textarea> </td> <td>Option Type:</td> <td> <select name="optionDrop" onClick="getDropDown()"> <option value="">Please Select</option> <option value="abc">ABC</option> <option value="abcd">ABCD</option> <option value="abcde">ABCDE</option> <option value="trueorfalse">True or False</option> <option value="yesorno">Yes or No</option> </select> </td> <tr> <td colspan="2"></td> <td>Number of Answers:</td> <td> <span id="na">N/A</span> <select name="numberDrop" id="numberDropId" onChange="getButtons()"> <option value=""></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </td> </tr> </table> </form> Similar TutorialsHelp is greatly appreciated!! I have two radio buttons on a form. I wish for one button to show a div that's hidden with {display:none;}, and the other to put it back to being hidden when selected. My code seemed sound to me but in firefox it doesn't really work, only in internet explorer. I would like to keep the coding as simple as possible: Code: style: .hidden{display:none;} script: function show() {document.getElementById("hide").style.display = 'inline'} function hidden() {document.getElementById("hide").style.display = 'none'} body: How old are you?<br/> <input type="radio" name="age" onclick="return hidden();" value="yes"/>over 25<br/> <input type="radio" name="age" onclick="return show();" value="no"/>25 or under<br/> <div id=hide class="hidden"> Do you have over 2 years of experience?<br/> <input type="radio" name="experience" value="yes"/>yes<br/> <input type="radio" name="experience" value="no"/>no<br/> </div> I am hoping that someone can figure out why this simple javascript works fine in Firefox, but not in IE8. I appreciate any help. PS: I see it DOES work in IE9... but I can't use it if I cannot make it work in IE8 as well. Sincerely, Buffmin Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>test</title> <script type="text/javascript" src="jquery-1.6.2.js"></script> <script type="text/javascript"> $(document).ready(function() { switches = $('#switches > li'); slides = $('#slides > div'); switches.each(function(idx) { $(this).data('slide', slides.eq(idx)); }).hover( function() { switches.removeClass('active'); slides.removeClass('active'); $(this).addClass('active'); $(this).data('slide').addClass('active'); }); }); </script> <style type="text/css"> #switches .active { font-weight: bold; } #slides div { display: none; } #slides div.active { display: block; } </style> </head> <body> <ul id="switches"> <li class="active">First slide</li> <li>Second slide</li> <li>Third slide</li> <li>Fourth slide</li> </ul> <div id="slides"> <div class="active">Well well.</div> <div>Oh no!</div> <div>You again?</div> <div>I'm gone!</div> </div> </body> </html> Hi there i have been looking around the internet for a way to resolve the problem i have, admittedly i may well of read the answer several times but being relatively new to JavaScript i am still unclear on much of the terminology. Well basically my problem is that i have a piece of code which wen tested on my mac i was using Firefox, safari, opera etc. all these worked fine when it came to pc testing with internet explorer i was presented with the following errors..... Error Details: 1) Line:32 Char:16 Error: 'getElementsByTagName(...).0.src' is null or not an object Code:0 URL:http://www.janedelacey.co.uk/html/press.html 2) Line:53 Char:41 Error: Object doesnt support this property or method Code:0 URL:http://www.janedelacey.co.uk/html/press.html The url is a clients webpage i dont think this has any effect on the issue. Here is the code for the page if this helps anyone in helping me resolve the issue! Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <LINK REL="SHORTCUT ICON" HREF="../images/favicon.ico"> <link rel="stylesheet" type="text/css" href="../css/layout.css"> <title> Jane De-Lacey - Press </title> <link rel="shortcut icon" href="favicon.ico" > <meta name="description" content="Jane De Lacey is a freelance lingerie designer and manufacturer using the finest silk to create Bras, Briefs, Camisoles, Slip, Dresses and Sleepmasks. The latest collection is called the 'L.A Collection'. "> <meta name="keywords" content="Jane De Lacey, Jane DeLacey, Lingerie, 100% Silk, Bra, Knickers, Briefs, Slips, Camisoles, Dresses, Sleepmasks, Underwear, Sheer Silk, Chemise"> <!--[if lt IE 8]> <style media="screen,projection" type="text/css"> #jgal1 li { filter: alpha(opacity=40); } #jgal1 li.active, #jgal1 li:hover { filter: alpha(opacity=100); } </style> <![endif]--> <script type="text/javascript">document.write("<style type='text/css'> #press_gallery { display: none; } </style>");</script> <!--[if lt IE 6]><style media="screen,projection" type="text/css">#press_gallery { display: block; }</style><![endif]--> <script type="text/javascript"> var gal1 = { init : function() { if (!document.getElementById || !document.createElement || !document.appendChild) return false; if (document.getElementById('press_gallery')) document.getElementById('press_gallery').id = 'jgal1'; var li = document.getElementById('jgal1').getElementsByTagName('li'); li[0].className = 'active'; for (i=0; i<li.length; i++) { var url = li[i].getElementsByTagName('img')[0].src; var url_array = url.split("/"); var j = url_array.length - 1; var thumb_path = "../images/thumbs/"; li[i].style.backgroundImage = 'url(' + thumb_path + url_array[j] + ')'; li[i].style.backgroundRepeat = 'no-repeat'; li[i].title = li[i].getElementsByTagName('img')[0].alt; gal1.addEvent(li[i],'click',function() { var im = document.getElementById('jgal1').getElementsByTagName('li'); for (j=0; j<im.length; j++) { im[j].className = ''; } this.className = 'active'; }); } }, addEvent : function(obj, type, fn) { if (obj.addEventListener) { obj.addEventListener(type, fn, false); } else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } obj.attachEvent("on"+type, obj[type+fn]); } } } gal1.addEvent(window,'load', function() { gal1.init(); }); </script> </head> <body> <div id="content"> <div id="navcontainer"> <div id="topbanner"> <a href="home.html"><img src="../images/logo1.gif" border="none" width="380" height="50"alt="Home - Jane DeLacey"/></a> </div> <ul id="nav"> <li id="nav-home"><a href="home.html">Home</a></li> <li id="nav-shop"><a href="shop.html">Collections</a></li> <li id="nav-press"><a href="press.html">Press</a></li> <li id="nav-about"><a href="about.html">About Us</a></li> <li id="nav-contact"><a href="contact.html">Contact Us</a></li> </ul> </div> <div id="product"> <div id="product_graf"> <img src="../images/top_lines.gif" alt="Side Graphic" height="300px"> </div> <div id="press"> <div id="press_text"> click logo to view image, click image to enlarge </div> <div id="press_pics"> <ul id="press_gallery"> <li><a href="../images/press/marieclaire.jpg"><img src="../images/press/marieclaire.jpg"width="475px" height="500px" alt="Marie Claire featuring Victoria Beckham" border="none" ></a></li> <li><a href="../images/press/vogue1.jpg"<img src="../images/press/vogue1.jpg"width="350px" height="500px" alt="Vogue" border="none"></a></li> <li><a href="../images/press/elle1.jpg"<img src="../images/press/elle1.jpg"width="350px" height="500px" alt="ELLE" border="none" ></a></li> <li><a href="../images/press/wwd1.jpg"<img src="../images/press/wwd1.jpg"width="350px" height="500px" alt="Womens Wear Daily" border="none" ></a></li> <li><a href="../images/press/brides.jpg"<img src="../images/press/brides.jpg" width="350px" height="500px"alt="Brides" border="none" ></a></li> <li><a href="../images/press/wwd2.jpg"<img src="../images/press/wwd2.jpg" width="350px" height="500px"alt="ELLE" border="none" ></a></li> <li><a href="../images/press/elle2.jpg"<img src="../images/press/elle2.jpg" width="350px" height="500px"alt="ELLE" border="none" ></a></li> <li><a href="../images/press/hg.jpg"<img src="../images/press/hg.jpg" width="350px" height="500px"alt="Homes and Gardens" border="none" ></a></li> <li><a href="../images/press/vogue2.jpg"<img src="../images/press/vogue2.jpg" width="350px" height="500px"alt="Vogue" border="none" ></a></li> <li><a href="../images/press/wwd3.jpg"<img src="../images/press/wwd3.jpg" width="350px" height="500px"alt="Womens Wear Daily" border="none" ></a></li> <li><a href="../images/press/elle3.jpg"<img src="../images/press/elle3.jpg" width="350px" height="500px"alt="ELLE" border="none" ></a></li> <li><a href="../images/press/status1.jpg"<img src="../images/press/status1.jpg" width="350px" height="500px"alt="Status" border="none" ></a></li> <li><a href="../images/press/elle4.jpg"<img src="../images/press/elle4.jpg"width="500px" height="350px" alt="ELLE" border="none" ></a></li> <li><a href="../images/press/wwd4.jpg"<img src="../images/press/wwd4.jpg"width="350px" height="500px" alt="Womens Wear Daily" border="none" ></a></li> <li><a href="../images/press/status2.jpg"<img src="../images/press/status2.jpg" width="350px" height="500px"alt="Status" border="none" ></a></li> <li><a href="../images/press/fashiondaily.jpg"<img src="../images/press/fashiondaily.jpg" width="500px" height="350px"alt="Fashion Daily" border="none" ></a></li> <li><a href="../images/press/eve.jpg"<img src="../images/press/eve.jpg" width="350px" height="500px"alt="Eve" border="none" ></a></li> <li><a href="../images/press/observer.jpg"<img src="../images/press/observer.jpg" width="350px" height="500px"alt="Observer Magazine" border="none" ></a></li> <li><a href="../images/press/telegraph.jpg"<img src="../images/press/telegraph.jpg" width="350px" height="500px"alt="Telegraph" border="none" ></a></li> <li><a href="../images/press/financialtimes.jpg"<img src="../images/press/financialtimes.jpg" width="350px" height="500px"alt="Financial Times" border="none" ></a></li> <li><a href="../images/press/linbuyer.jpg"<img src="../images/press/linbuyer.jpg" width="350px" height="500px"alt="Lingerie Buyer Blog" border="none" ></a></li> <li><a href="../images/press/juice1.jpg"<img src="../images/press/juice1.jpg" width="350px" height="500px"alt="Juice Brighton Magazine" border="none" ></a></li> <li><a href="../images/press/ideal.jpg"<img src="../images/press/ideal.jpg" width="350px" height="500px"alt="Ideal" border="none" ></a></li> <li><a href="../images/press/drapers.jpg"<img src="../images/press/drapers.jpg" width="500px" height="200px"alt="Drapers" border="none" ></a></li> <li><a href="../images/press/juice2.jpg"<img src="../images/press/juice2.jpg" width="500px" height="350px"alt="Juice Brighton Magazine" border="none" ></a></li> </ul> </div> <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> </div> <div id="footer"> <ul id="footer_nav"> <li><a href="terms.html">terms & conditions</a></li> <li><a href="delivery.html">delivery</a></li> <li><a href="acknowledge.html">acknowledgments</a></li> <li><a href="contact.html">contact us</a></li> </ul> </div> </div> </div> </body> </html> I know most of this code will not be relevant but i thought adding the whole pages code made more sense? Thank you in advance for any help received! Tom I'm using jQuery+drupal and some jQuery plugins. All is ok with Firefox. But in IE's i'm receiving problem like this. Line: 1 Char: 1 Error: object expected URL: http://businessway.am I have included .js files. How to know where is the problem? In which file? Line 1? Which file? If you can please check with this address: http://businessway.am I am trying to set up some code to control a mouseover popup image. I have the script that works except in certain browsers the results are different. This is the page: http://www.huguenotbats.com/redesignfiles/team.php (just mouse over the first players name). Here is the script: Code: <script type="text/javascript"> function ShowPopup(hoveritem) { hp = document.getElementById("hoverpopup"); // Set position of hover-over popup hp.style.top = hoveritem.offsetTop +115; hp.style.left = hoveritem.offsetLeft +450; //Set popup to visible hp.style.visibility = "Visible"; } function HidePopup() { hp = document.getElementById("hoverpopup"); hp.style.visibility = "Hidden"; } </script> And here is the html code: Code: <tr> <td width="10%" align="center"> 1 </td> <td width="45%" align="center"> <a id="hoverover" style="cursor:default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();" href="bio/amentbio.php" target="_blank" onClick="window.open('bio/amentbio.php','Ryan Ament Bio','height=431,width=649,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no'); return false;"> Ryan Ament </a> <div id="hoverpopup" style="visibility:hidden; position:absolute; top:100; left:350;"><img src="bio/amentthumb.png"></div> </td> </tr> The problem is this: When tested on a Mac (running OS X 10.3.9) in Opera the result is perfect in Safari the popup image is too far down and to the left in IE the script causes an error (Invalid procedure call or argument @ Line 13) When tested on a PC (running XP Home Service Pack 3) in Opera the result is perfect in IE the image is only a tiny bit too far down I can't find any rhyme or reason as to what the problem is or how to fix it (I'm still fairly new to JavaScript) but I really need to get this fixed the best I can so that the site redesign can be submitted to my client. Any help would be much appreciated. Crystal Hi, I'm having problems tracking down the code that causes IE to throw an error where all other browsers work just fine. I have attached the menu.js file, two style sheets (one for IE, the other for all browsers, css code for menu is at the end), and a body.html file that calls the menu. Of course these are uploaded as text files, but please feel free to rename and run the body file! The IE error states that it's looking for an object after the script tag on line 18 of the body file that creates menu settings. What is wrong with this line, and how can I fix it? Many thanks for any help that can be provided! This is a common issue, however, I haven't found anything ( yet ) that points out a solution that I can find in my code. As usual, this site works with every single browser known to man ...........except for any version of IE. I have tried using IE's devel tools to no avail ....though I'm a complete newb, so that isn't saying much. Code??? Here's the section IE complains about: Code: function display(str) { var nodeList = xmlDoc.getElementsByTagName("item"); var cnt = 0; var list = "<hr />"; for(var i=0; i< nodeList.length; i++) { cnt++; // Get vars from XML title = nodeList[i].getElementsByTagName("title")[0].childNodes[0].nodeValue; author = nodeList[i].getElementsByTagName("author")[0].childNodes[0].nodeValue; pubDate = nodeList[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue; call = nodeList[i].getElementsByTagName("call")[0].childNodes[0].nodeValue; cover = nodeList[i].getElementsByTagName("cover")[0].childNodes[0].nodeValue; link = nodeList[i].getElementsByTagName("link")[0].childNodes[0].nodeValue; summary = nodeList[i].getElementsByTagName("summary")[0].childNodes[0].nodeValue; style = nodeList[i].getElementsByTagName("class")[0].childNodes[0].nodeValue; page = nodeList[i].getElementsByTagName("page")[0].childNodes[0].nodeValue; category = nodeList[i].getElementsByTagName("category")[0].childNodes[0].nodeValue; I opened this with Firebug and I see nothing of interest. Specifically, IE complains about line 86: Code: summary = nodeList[i].getElementsByTagName("summary")[0].childNodes[0].nodeValue; Thanks for reading ~ Bub **** UPDATE ***** Well ...it looks like I can't have null values in any elements ( in the xml document ). How do you experts satisfy this requirement in an elegant fashion. Since there is no data for certain elements, I'm looking for a reasonable failover solution. Empty quotes? ..... still experimenting. A script produces the xml file from a database so some elements do not have data for certain child elements. **** UPDATE 2 ***** Using the Unicode non-breaking space in the xml file for empty child elements. Works, but if you have a cooler solution, let me know. Thanks! I have javascript code in my site. It works in FireFox but doesn't work in IE. The page is http://omidpand.ir/search.html First select something from first combobox when u open second combobox the javascript code should change latin characters with persian one, but it doesn't do it. I am using HAPedit for HTML/Javascript and it used to work alright by clicking Display -> Browse with -> Default Browser(Internet Explorer). But since last one or two days it gives the following error "The page cannot be displayed" and the following is shown in the URL bar http://localhost/helloworld.html 2. But, however, if I navigate to the file by using File -> Open of the IE, the result is shown correctly. 3. What has gone wrong?? i'm looking for a function to check for the browser version and NOT run a script if the user is using internet explorer 7 or less something like <!--[if gte IE 7]> alert(internet explorer 6 sucks) <!--[else]> alert(internet explorer 7 or greater is better but it still sucks) <![endif]--> and if i just use "lte IE 7" instead of gte IE 7 it will exclude firefox... so that's why i prefer to use a "else" statement.... instead you got something better to suggest thanks!! Hi There, Can anyone explain why the following XMLHttpRequest.open call fails on IE browsers, but works fine in Firefox and Chrome? Code: <html> <head> </head> <script type="text/javascript"> if( window.XMLHttpRequest ) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET","test.xml",false); // I show an "access is denied error in IE" xhttp.send(""); document.write( xhttp.responseXML.getElementsByTagName("simple")[0].childNodes[0].nodeValue ); </script> <body> </body> </html> The "text.xml" file resides in the same location (local HDD folder on the pc this is running on) as the html page. And the contents of "test.xml" are shown below: Code: <simple> Hello </simple> Obviously its just a very simple example that should just display "Hello" when loaded, but it fails to work in IE. Hi there - I was wondering if anyone out there could help me I'm redoing my site from many years ago - www.industrialarts.co.uk It contains a "Conveyor" - to which I've always wanted to add a "Lightbox" effect. Well - the good news is that I've managed to get a test page up and running and it's doing exactly what I want it to in Firefox, Chrome, Opera and in Safari However .. in Internet Explorer 8 .. it ain't good. The scripts on the page seem not to work at all. (In Internet Explorer 7, it's worse as the formatting is haywire too - but I'll try to fix one thing at a time) http://www.industrialarts.co.uk/test/chairs/chairs.html So - if anybody could be good enough to take a look at my test page and offer any suggestions for getting it running on Internet Explorer too .. or just where to look for answers - I'd be massively grateful My apologies also as I'm a dabbler with this stuff (normally a woodworker) Cheers, Jol when this page is viewed in IE (8), IE tells me there's an error on the page. Quote: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Win64; x64; Trident/4.0) Timestamp: Tue, 17 May 2011 14:29:31 UTC Message: Invalid argument. Line: 7 Char: 17603 Code: 0 URI: http://cpanel4.frontline.net/~ggarch...cufon/cufon.js Here's what that Javascript file looks like: http://pastebin.com/T2vgugm2 I honestly know very little about Javascript. I installed a wordpress theme that already contained this bit of Javascript so please be patient with me on this one. please advise. thanks in advance! Hello, im new and hope you can help me out. I am running some javascript on my vbulletin forum. One is for some ad network to display ads, I noticed this working in firefox and chrome but not IE. After some investigation I realised my analytics javascript snippet is conflicting, if i remove the javascript for my analytics then the ads show in all web browsers. The two pieces of code a Analytics; Code: <script src="/mint/?js" type="text/javascript"></script> Ad network; Code: <script type="text/javascript"> var EB_campid='5336510241'; </script> <script src="http://www.zintext.com/showads.js" type="text/javascript"></script> Any help appreciated. Dave. Hello, I'm new to Javascript programming. I have designed a Javascript to carry information from one page to another. It works fine in firefox but does not work in internet explorer. Is there some coding that needs to be specified for my script to work in ie? Thanks Hello, I have a xmlHttpRequest that was working in Internet explore 6,7 and now is broken in the new Internet explore 8. Can anyone help me pinpoint the problem here? The Error console says this. Invalid procedure call or argument: Code: req.base_open('get', ginf.host + '/includes/process.php?action=jstest&' + failures, true); Screen Captu http://i31.tinypic.com/2v81rg6.jpg This works in Firefox and the older Internet explorers. So I"m not sure what Microsoft did with Internet Exploder 8. Is there syntax error or something with it that the other browser ignored? What is wrong with it? This is the full javascript file if you like to look. http://pastebin.ca/1515445 hey just wondering if anyone could help me with a problem im having with this menu for a website i got a chained menu javascript downloaded and all the data entered for it it will work in firefox but wont in internet explorer and i just dont understand why http://www.jomcfall97.talktalk.net/index1.html its the menu on the right hand side this is the error message Message: Object doesn't support this property or method Line: 247 Char: 5 Code: 0 URI: http://www.jomcfall97.talktalk.net/chainedmenu.js Here are lines 244 - 248 function initListGroup(n) { var _content=cs_findContent(n), count=0; if (_content!=null) { content=new cs_contentOBJ("cs_"+n,_content.menu); cs_content[cs_content.length]=content; and heres the full chainedmenu.js Code: var _disable_empty_list=false; var _hide_empty_list=false; var onclickaction="alert" function goListGroup(){ for (i=arguments.length-1;i>=0; i--){ if (arguments[i].selectedIndex!=-1){ var selectedOptionvalue=arguments[i].options[arguments[i].selectedIndex].value if (selectedOptionvalue!=""){ if (onclickaction=="alert") alert(selectedOptionvalue) else if (newwindow==1) window.open(selectedOptionvalue) else window.location=selectedOptionvalue break } } } } if (typeof(disable_empty_list)=="undefined") { disable_empty_list=_disable_empty_list; } if (typeof(hide_empty_list)=="undefined") { hide_empty_list=_hide_empty_list; } var cs_goodContent=true, cs_M="M", cs_L="L", cs_curTop=null, cs_curSub=null; function cs_findOBJ(obj,n) { for (var i=0; i<obj.length; i++) { if (obj[i].name==n) { return obj[i]; } } return null; } function cs_findContent(n) { return cs_findOBJ(cs_content,n); } function cs_findM(m,n) { if (m.name==n) { return m; } var sm=null; for (var i=0; i<m.items.length; i++) { if (m.items[i].type==cs_M) { sm=cs_findM(m.items[i],n); if (sm!=null) { break; } } } return sm; } function cs_findMenu(n) { return (cs_curSub!=null && cs_curSub.name==n)?cs_curSub:cs_findM(cs_curTop,n); } function cs_contentOBJ(n,obj){ this.name=n; this.menu=obj; this.lists=new Array(); this.cookie=""; }; cs_content=new Array(); function cs_topmenuOBJ(tm) { this.name=tm; this.items=new Array(); this.df=0; this.addM=cs_addM; this.addL=cs_addL; } function cs_submenuOBJ(dis,link,sub) { this.name=sub; this.type=cs_M; this.dis=dis; this.link=link; this.df=0; var x=cs_findMenu(sub); this.items=x==null?new Array():x.items; this.addM=cs_addM; this.addL=cs_addL; } function cs_linkOBJ(dis,link) { this.type=cs_L; this.dis=dis; this.link=link; } function cs_addM(dis,link,sub) { this.items[this.items.length]=new cs_submenuOBJ(dis,link,sub); } function cs_addL(dis,link) { this.items[this.items.length]=new cs_linkOBJ(dis,link); } function cs_showMsg(msg) { window.status=msg; } function cs_badContent(n) { cs_goodContent=false; cs_showMsg("["+n+"] Not Found."); } function cs_optionOBJ(text,value) { this.text=text; this.value=value; } function cs_emptyList(list) { for (var i=list.options.length-1; i>=0; i--) { list.options[i]=null; } } function cs_refreshList(list,opt,df) { cs_emptyList(list); for (var i=0; i<opt.length; i++) { list.options[i]=new Option(opt[i].text, opt[i].value); } if (opt.length>0) { list.selectedIndex=df; } } function cs_getOptions(menu) { var opt=new Array(); for (var i=0; i<menu.items.length; i++) { opt[i]=new cs_optionOBJ(menu.items[i].dis, menu.items[i].link); } return opt; } function cs_updateListGroup(content,idx,sidx,mode) { var i=0, curItem=null, menu=content.menu; while (i<idx) { menu=menu.items[content.lists[i++].selectedIndex]; } if (menu.items[sidx].type==cs_M && idx<content.lists.length-1) { var df=cs_getIdx(mode,content.cookie,idx+1,menu.items[sidx].df); cs_refreshList(content.lists[idx+1], cs_getOptions(menu.items[sidx]), df); if (content.cookie) { cs_setCookie(content.cookie+"_"+(idx+1),df); } if (idx+1<content.lists.length) { if (disable_empty_list) { content.lists[idx+1].disabled=false; } if (hide_empty_list) { content.lists[idx+1].style.display=""; } cs_updateListGroup(content,idx+1,df,mode); } } else { for (var s=idx+1; s<content.lists.length; s++) { cs_emptyList(content.lists[s]); if (disable_empty_list) { content.lists[s].disabled=true; } if (hide_empty_list) { content.lists[s].style.display="none"; } if (content.cookie) { cs_setCookie(content.cookie+"_"+s,""); } } } } function cs_initListGroup(content,mode) { var df=cs_getIdx(mode,content.cookie,0,content.menu.df); cs_refreshList(content.lists[0], cs_getOptions(content.menu), df); if (content.cookie) { cs_setCookie(content.cookie+"_"+0,df); } cs_updateListGroup(content,0,df,mode); } function cs_updateList() { var content=this.content; for (var i=0; i<content.lists.length; i++) { if (content.lists[i]==this) { if (content.cookie) { cs_setCookie(content.cookie+"_"+i,this.selectedIndex); } if (i<content.lists.length-1) { cs_updateListGroup(content,i,this.selectedIndex,""); } } } } function cs_getIdx(mode,name,idx,df) { if (mode) { var cs_idx=cs_getCookie(name+"_"+idx); if (cs_idx!="") { df=parseInt(cs_idx); } } return df; } function _setCookie(name, value) { document.cookie=name+"="+value; } function cs_setCookie(name, value) { setTimeout("_setCookie('"+name+"','"+value+"')",0); } function cs_getCookie(name) { var cookieRE=new RegExp(name+"=([^;]+)"); if (document.cookie.search(cookieRE)!=-1) { return RegExp.$1; } else { return ""; } } // ---- function addListGroup(n,tm) { if (cs_goodContent) { cs_curTop=new cs_topmenuOBJ(tm); cs_curSub=null; var c=cs_findContent(n); if (c==null) { cs_content[cs_content.length]=new cs_contentOBJ(n,cs_curTop); } else { delete(c.menu); c.menu=cs_curTop; } } } function addList(n,dis,link,sub,df) { if (cs_goodContent) { cs_curSub=cs_findMenu(n); if (cs_curSub!=null) { cs_curSub.addM(dis,link||"",sub); if (typeof(df)!="undefined") { cs_curSub.df=cs_curSub.items.length-1; } } else { cs_badContent(n); } } } function addOption(n,dis,link,df) { if (cs_goodContent) { cs_curSub=cs_findMenu(n); if (cs_curSub!=null) { cs_curSub.addL(dis,link||""); if (typeof(df)!="undefined") { cs_curSub.df=cs_curSub.items.length-1; } } else { cs_badContent(n); } } } function initListGroup(n) { var _content=cs_findContent(n), count=0; if (_content!=null) { content=new cs_contentOBJ("cs_"+n,_content.menu); cs_content[cs_content.length]=content; for (var i=1; i<initListGroup.arguments.length; i++) { if (typeof(arguments[i])=="object" && arguments[i].tagName && arguments[i].tagName=="SELECT") { content.lists[count]=arguments[i]; arguments[i].onchange=cs_updateList; arguments[i].content=content; arguments[i].idx=count++; } } if (content.lists.length>0) { cs_initListGroup(content,content.cookie); } } } function resetListGroup(n) { var content=cs_findContent("cs_"+n); if (content!=null && content.lists.length>0) { cs_initListGroup(content,""); } } any help appreciated as ive just come to a standstill over this thanks Here I am again. In Internet Explorer 7, running on Windows Vista I am testing a project. I get an error message when the page loads to the effect: line 31 char 29 error: object does not support this property or method code 0 This is a one page site and this message comes up on every page load. So I have a good idea what it is complaining about. But in I.E., how do I determine 'line 29'? Where does it start counting, and what type of lines would it skip? I.E. loads source into notepad and notepad does not number the lines. Further, the lines in the source are formatted unix style ("\n" line feed endings instead of line feed/carriage return: as in Windows). Long lines are wrapped, so it is unclear where one line ends and the next starts. Are there any good web dev tools for I.E.(preferreably open source)? Thank you; JK I have the following Javascript function that just refuses to work in Internet Explorer (since IE is absolute .......). Can anybody tell me why this wouldn't be working in IE and what I need to do to fix it? I am new to Javascript so don't really have any idea Code: function displaymember() { var d = new Date(); var curr_date = d.getDate(); if (curr_date < 10) curr_date = "0" + curr_date; var curr_month = d.getMonth(); curr_month++; if (curr_month < 10) curr_month = "0" + curr_month; var curr_year = d.getFullYear(); //alert("date="+curr_date+" month="+curr_month+" year="+curr_year); for (i = 0; i < x.length; i++) { membershipstatus = (x[i].getElementsByTagName("membership_status")[0].childNodes[0].nodeValue); name = (x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue); body = (x[i].getElementsByTagName("body_type")[0].childNodes[0].nodeValue); ethnicity = (x[i].getElementsByTagName("ethnicity")[0].childNodes[0].nodeValue); sex = (x[i].getElementsByTagName("sex")[0].childNodes[0].nodeValue); profession = (x[i].getElementsByTagName("profession")[0].childNodes[0].nodeValue); seeking = (x[i].getElementsByTagName("seeking")[0].childNodes[0].nodeValue); date = (x[i].getElementsByTagName("date_joined")[0]); month = (date.getElementsByTagName("month")[0].childNodes[0].nodeValue); year = (date.getElementsByTagName("year")[0].childNodes[0].nodeValue); newa = document.createElement('a'); aIdName = 'my' + i + 'a'; ahref = '#'; aclick = 'show(' + i + ')'; newa.setAttribute('id', aIdName); newa.setAttribute('href', ahref); newa.setAttribute('onclick', aclick); newa.innerHTML = name + " | " + body + " " + ethnicity + " " + sex + " " + profession + " with " + membershipstatus + " membership seeks " + seeking + "<br/>"; if (curr_month == month && curr_year == year) { document.getElementById("member").appendChild(newa); } } } Sorry fellas, I am a complete noob I am trying to detect if a users browser is Internet Explore Version 9 the subsequently redirect that browser to a new page that is IE 9 specific in my directory. My code does NOT seem to be working. Could any of you kind folks take a look and see the mistake? <script language="JavaScript" type="text/JavaScript"> if(navigator.appName == "Microsoft Internet Explorer"&& navigator.appVersion >=8) { window.location = "SeansWebsite_2012_IE9.html" } <!-- the page that i am starting on is "SeansWebsite_2012.html"--> </script> |