JavaScript - Javascript Not Working As Desired
Greetings to Everyone
Professionally I'm not a programmer. So i have no tough idea about variables,loops,functions etcetra, So can anybody help assemble this piece of Javascript to work properly. In both cases the script show either "OK" or "Down" i can't make it to work. I hope a programming guru will help me to fix this javascript code. Code: <html> <head> <title>My Intranet Page</title> </head> <body> <script> function doNoConnectFunction() { document.getElementById("intstatus").innerHTML = "Internet is Down"; document.getElementById("wsstatus").innerHTML="Internal Web Server is Down"; document.getElementById("fntcolor").style.color="#0000FF"; } function doConnectFunction() { document.getElementById("intstatus").innerHTML = "Internet is Ok"; document.getElementById("wsstatus").innerHTML="Internal Web Server is Ok"; document.getElementById("fntcolor").style.color="#FF0000"; } var i = new Image(); i.onload = doConnectFunction; i.onerror = doNoConnectFunction; i.src = 'http://www.aapress.com.au/img/71f.gif?d=' + escape(Date()); var j = new Image(); j.onload = doConnectFunction; j.onerror = doNoConnectFunction; j.src = 'http://192.168.0.2/imgages/err.jpg' + escape(Date()); </script> <font face="Arial"> <b><font size="4">Works only on Javascript Enabled Browsers</font></b> <br> <br> <table border=1 cellpadding=2> <tr> <td align=right valign=top>Internet Status</td> <td><span id="fntcolor"><span id="intstatus"></span><font></td> </tr> <tr> <td align=right valign=top>Web Server Status</td> <td><span id="fntcolor"><span id="wsstatus"></span><font></td> </tr> </table> </body> </html> Thankyou for taking time to analyze the script layman Similar Tutorialsi have this part of code in JS: Code: var receiveReq = getXmlHttpRequestObject(); function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } } function getChatText() { if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { receiveReq.open("GET","getChat_xml.php?chat=1&last=7", true); receiveReq.onreadystatechange = handleReceiveChat; receiveReq.send(); } } function handleReceiveChat() { if (receiveReq.readyState == 4) { var chat_div = document.getElementById('div_chat'); var xmldoc = receiveReq.responseXML; var message_nodes = xmldoc.getElementsByTagName("message"); } } then in my getChat_xml.php i have: Code: $xml = '<?//xml version="1.0" ?><root>'; $last = 7; $sql = "SELECT message_id, user_name, message, date_format(post_time, '%h:%i') as post_time" . " FROM message WHERE chat_id = " . db_input($_GET['chat']) . " AND message_id = " . $last; $message_query = db_query($sql); while($message_array = db_fetch_array($message_query)) { $xml .= '<message id="' . $message_array['message_id'] . '">'; $xml .= '<user>' . htmlspecialchars($message_array['user_name']) . '</user>'; $xml .= '<text>' . htmlspecialchars($message_array['message']) . '</text>'; $xml .= '<time>' . $message_array['post_time'] . '</time>'; $xml .= '</message>'; } $xml .= '</root>'; echo $xml; i get a "cannot cal a method getElementsByTagName of null" ??? i have no idea whats going on, help please? thanks Ill tell you the story and then simplify it ok i have a computer site that you can build your own computer and whatnot but i just recently thought about how not everyone knows which parts are needed in a computer... my first design of the site had the name of the part in the select box as default but now i removed the name of each part outside of the select boxes but the problem now is i need some type of onLoad event to happen when the page loads to call out the functions that are associated with the selected boxes...... i have 2 fuctions in an external js file Code: function swapImage(sel,id){ document.getElementById(id).src = sel.value.split('#')[1]; } and Code: function Calculate(){ var a = parseFloat(document.comp.caseselect.value.split('#')[0]); var b = parseFloat(document.comp.powersupply.value.split('#')[0]); var sum = a+b; document.getElementById("total").innerHTML = '$'+sum; } when someone selects an item it adds the price to the price of other selected items and shows the total price elsewhere on the page... also shows a picture of the selected item on the page.. im just going to show the first select box to show you how all my select boxes are written Code: <p align="left">CASE</p> <center> <select name="caseselect" style="width:625px" onchange="Calculate(); swapImage(this,'caseimg');"> <option value="50#COOLER MASTER Elite 310red.jpg" selected="1">COOLER MASTER Elite 310 Red ($50.00)</option> <option value="50#COOLER MASTER Elite 310blue.jpg">COOLER MASTER Elite 310 Blue ($50.00)</option> <option value="50#COOLER MASTER Elite 310orange.jpg">COOLER MASTER Elite 310 Orange ($50.00)</option> <option value="50#COOLER MASTER Elite 310silver.jpg">COOLER MASTER Elite 310 Silver ($50.00)</option> </select> *not that it matters but yes there is an ending center in my html but its at the end of the group the image is sent here Code: <img src="start.jpg" id="caseimg" /> and the price is sent here Code: <span style="color:black; font-size:20pt">YOUR PRICE UPDATE</span><br /> <span id="total" style="color:white; font-size:32pt">$0 Nothing Selected</span> code works perfectly fine ONCE YOU SELECT SOMETHING ELSE but i need it to work when the page loads Thanks for looking! I have a widget that lives on a blank/fresh Blogger.com account, and with test pictures, it seems to work fine. However, when I throw in Amazon ads it breaks. Images with links as sample data, rotate and display fine. Changing them to amazon code, they break. What's going on? Am I missing an escape character? Code: <script language="Javascript" type="text/JavaScript"> var ad = new Array() ad[0]=' <iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=netbooknewsco-20&o=1&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B0051VVOB2" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> ' ad[1]='<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=netbooknewsco-20&o=1&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B0051VVOB2" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> ' function randomorder(targetarray, spacing){ var randomorder=new Array() var the_one var z=0 for (i=0;i<targetarray.length;i++) randomorder[i]=i while (z<targetarray.length){ the_one=Math.floor(Math.random()*targetarray.length) if (targetarray[the_one]!="_selected!"){ document.write(targetarray[the_one]+spacing) targetarray[the_one]="_selected!" z++ } } } </script> <script language="Javascript" type="text/javascript" ></script> <script> randomorder(ad, ' ') </script> Hi, I Have been working on a archive/library for our animators here, with images of old and useful models/3d work. to help them out and save them some time, I wanted to add the ability to click on a jpeg and open the folder where the files are stored for the desired character/set. Being a animator myself, and working for a small company (who have no javascript programmers) we have little to no knowledge of the code and would appreciate any help possible. this is what i have come up with so far Code: <HEAD> <SCRIPT LANGUAGE="JavaScript"> function DriveList() { var folder=document.Drive.Name.options[document.Drive.Name.selectedIndex].value; document.frames['MyComputer'].location.href = folder; } function FolderChoose() { var location=document.UserLocation.FolderLocation.value; document.frames['MyComputer'].location.href = location; } </script> </HEAD> <BODY> <FORM NAME="UserLocation"> <P><font size="2">Type in a Folder Location: </font> <INPUT TYPE="text" name="FolderLocation" length="25" size="20"> <INPUT TYPE="button" value="Open Folder" onClick="FolderChoose();"></P> </FORM> <IFRAME NAME="MyComputer" SRC="about:blank" WIDTH="50%" HEIGHT="20%"></IFRAME> </CENTER> however this only allows the user to manually search for the files. Is it possible and what would be the best approach to achieving this. I have been using DreamWeaver to create the library if that is of any help. Thanks in advance! Matt I hope I have this post in the right place! Any help would be very much appreciated... I have a feature on my website that allows users to choose the website background (using alternate css sheets) and then uses an externally linked javascript file to store the background choice as a cookie so it is consistent throughout the website. This works perfectly locally (i.e. when previewing my website on my computer) but now it is uploaded to my host it doesn't appear to be working. (with the same browser) My javascript is he http://www. b r p - e n v .com/javascript/backgroundchange.js (with no spaces) The website that the javascript file is linked to is http://www. b r p - e n v .com (with no spaces) In the head I have: <script type="text/javascript" src="../javascript/backgroundchange.js"></script> ...then I have: <body onload="set_style_from_cookie()"> ...and for users to choose which background: <form> <input type="image" src="../images/white-background-thumb.jpg" onclick="switch_style('bg1');return false;" name="theme" value="White" id="bg1"> etc... </form> My problem is: The background reverts back to the default when moving to a different page. This would indicate that the background choice is not being saved in cookies. But this works locally! I have tried putting the javascript directly onto each page but I still had the same problem. I hope someone can help, I will be so grateful if I can get this to work. Many thanks indeed! hereis the html file and javascripton click of this button a html ***************************** <table class=matcolor id=topnav cellspacing=0 cellpadding=0 width=550 border=0 bgcolor="#FFCCCC"> <tbody> <tr align=middle> <td id=menu1 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Desk Top Publishing </font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu2 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Transcription</font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu3 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Accounts Processing </font></div> </td> </tr> </tbody> </table> ***************************************** <script language=JavaScript> ix = document.getElementById('tblmenu1').getBoundingClientRect(); new ypSlideOutMenu("menu1", "right",ix.left + ix.right ,ix.bottom + 10); </script> **any thing i have to alter to work in firefox please help The javascript for the live chat button, makes the rest of the javascript for the navigation not work and only in internet explorer please help. <!--start http://www.livehelpnow.net --> <div style="text-align: center;"> <div> <script type="text/javascript"> var lhnJsHost = (("https:" == document.location.protocol) ? "https://" : "http://"); document.write(unescape("%3Cscript src='" + lhnJsHost + "www.livehelpnow.net/lhn/scripts/lhnvisitor.aspx?div=&zimg=33&lhnid=8456&iv=1&iwidth=101&iheight=35&zzwindow= 0&d=0&custom1=&custom2=&custom3=' type='text/javascript'%3E%3C/script%3E"));</script> </div> <div><a title="Help desk software" href="http://www.LiveHelpNow.net/" style="font-size:10px;" target="_blank">Help desk software</a></div> </div> <!--end http://www.livehelpnow.net --> document.write("<div class='nav' style='color: #0050A3;'>Products <img src='/images/dnav_arrow.gif' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/force_gauge.html'>Force Gauges <img src='/images/onav_arrow.gif' alt='' id='arrow4' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/instruments/menu-torque.html'>Torque Gauges <img src='/images/onav_arrow.gif' alt='' id='arrow4' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/instruments/menu-indicat.html'>Sensors & Indicators <img src='/images/onav_arrow.gif' alt='' id='arrow4' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/instruments/menu-loadcells.html'>Smart Load Cells <img src='/images/onav_arrow.gif' alt='' id='arrow4' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href=\"javascript: block_closed('menu3','arrow3');\">Test Stands</a> <a href=\"javascript: block_closed('menu3','arrow3');\"><img src='/images/unav_arrow.gif' alt='' id='arrow3' width='10' height='10' border='0'></a></div>"); document.write("<ul id='menu3' class='nav_l3'>"); document.write("<li><a href='/instruments/menu-stands.html'>Motorized Test Stands</a></li>"); document.write("<li><a href='/instruments/menu-manualstands.html'>Manual Test Stands</a></li>"); document.write("</ul>"); document.write("<div class='nav_l2'><a href='/instruments/menu-testsys.html'>Ergonomics Test Kits <img src='/images/onav_arrow.gif' alt='' id='arrow4' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/instruments/menu-grips.html'>Grips & Attachments <img src='/images/onav_arrow.gif' alt='' id='arrow4' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/instruments/menu-accessories.html'>Accessories <img src='/images/onav_arrow.gif' alt='' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/instruments/menu-software.html'>Software <img src='/images/onav_arrow.gif' alt='' id='arrow7' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/instruments/menu-testers.html'>Configuring A System <img src='/images/onav_arrow.gif' alt='' id='arrow4' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav_l2'><a href='/instruments/menu-legacy.html'>Legacy Products <img src='/images/onav_arrow.gif' alt='' id='arrow4' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav'><a href='/services/general.html'>Services <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav'><a href='/downloads.html'>Downloads <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav'><a href='/news.html'>News <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav'><a href='/warranty.html'>Product Registration <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav'><a href='/applications/index.html'>Gallery <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav'><a href='/inquiries.html'>Inquiries <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></a></div>"); document.write("<div class='nav'><a href='/about.html'>About Mark-10</a> <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></div>"); document.write("<div class='nav'><a href=\"javascript: block_closed('menu8','arrow6');\">Where To Buy <img src='/images/unav_arrow.gif' alt='' id='arrow6' width='10' height='10' border='0'></a></div>"); document.write("<ul id='menu8' class='nav_l3'>"); document.write("<li><a href='/order.html'>Ordering Direct</a></li>"); document.write("<li><a href='/distributor-us.html'>US Distributors</a></li>"); document.write("<li><a href='/distributor-intl.html'>International Distributors</a></li>"); document.write("<li><a href='/distributor-catalogs.html'>Catalog / Web Sales</a></li>"); document.write("<li><a href='/gsa.html'>US Government Purchases</a></li>"); document.write("<li><a href='/reseller.html'>Become a Reseller</a></li>"); document.write("</ul>"); document.write("<div class='nav'><a href=\"javascript: block_closed('menu9','arrow6');\">Resources <img src='/images/unav_arrow.gif' alt='' id='arrow6' width='10' height='10' border='0'></a></div>"); document.write("<ul id='menu9' class='nav_l3'>"); document.write("<li><a href='/tools/load.html'>Conversion Calculators</a></li>"); document.write("<li><a href='/faq.html'>Frequent Questions</a></li>"); document.write("</ul>"); document.write("<div class='nav'><a href='/contact.html'>Contact Us</a> <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></div>"); document.write("<div class='nav'><a href='/index.html'>Home</a> <img src='/images/onav_arrow.gif' width='10' height='10' border='0'></div>"); document.write("<div style='margin-top:15px;'><a href='http://www.mark-10.com/gsa.html'><img src='http://www.mark-10.com/images/GSA-small.gif' border='0'></></div>"); document.write("<div style='margin-top:15px;'><a href='http://www.mark-10.com/video.html'><img src='http://www.mark-10.com/images/Video-logo.jpg' width='154' height='54' border='0'></></div>"); document.write("<div style='margin-top:15px; text-align:center;'><a href='http://mark-10blog.blogspot.com'><img src='http://www.mark-10.com/images/blogger_logo.png' style='border:0;'><a href='http://www.facebook.com/pages/Mark-10-Force-Measurement/138943942794711'><img src='http://www.mark-10.com/images/facebook-logo.png' style='border:0;'></></div>"); //http://mark-10blog.blogspot.com Hello, I have a website that has some javascript on it, this works fine in Chrome, Opera, Safari and Firefox but not IE (any version I've tried). I've installed Firebug to try to help debug it but that doesn't pick up any issues. I'm not very good when it comes to javascript so would appreciate any assistance. The page with the javascript is he http://www.fantasy-f1-league.com/team3.php You will need to login, please use these details: user: test pw: test The javascript is supposed to update the "Remaining Budget" as you choose options from the dropdowns, it also does a few other things such as prevents submission of invalid team selections. Thanks for any assistance. David I thank you for the help in advance. I am a total noob when it comes to Javascript but I am working on learning it. I am working on a site and used this script http://livepipe.net/ It works in ie fine on their site, but not on mine. On my site it runs on every browser except IE and generates the errors below. It is probably a small issue but please don't get fustrated with my ignorance on js. I am very new to javascript. I usually pay for somebody to do it for me but my connect is not around right now so I am stuck fixing this issue. Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; Comcast Install 1.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729) Timestamp: Fri, 7 May 2010 15:55:29 UTC Message: Object doesn't support this property or method Line: 472 Char: 464 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 12 Char: 2854 Code: 0 URI: http://roadhouserestoration.com/site...y.js?ver=1.3.2 Message: Object doesn't support this property or method Line: 1 Char: 1 Code: 0 URI: http://roadhouserestoration.com/site...pts.js?ver=2.2 Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js Message: Object doesn't support this property or method Line: 460 Char: 1 Code: 0 URI: http://roadhouserestoration.com/js/all.js The actual address to the website is http://roadhouserestoration.com/site I have this problem with a javascript in Internet Explorer 7 and maybe 6. in all browsers it's working fine, but not in IE 7. i've tried security settings and adding to safe websites, but it's not working. the code if to disable some elements when the other is clicked. here's the code, what is wrong with it? Code: function checkthebox() { $('#toggleElement').attr('checked', true); if ($('#toggleElement').is(':checked')) { $('#vastematen .required').attr('disabled', true); $('#eigenmaten').removeAttr('disabled'); } else { $('#vastematen .required').removeAttr('disabled'); $('#eigenmaten').attr('disabled', true); } } function toggleStatus() { if ($('#toggleElement').is(':checked')) { $('#vastematen .required').attr('disabled', true); $('#eigenmaten :input').removeAttr('disabled'); } else { $('#vastematen .required').removeAttr('disabled'); $('#eigenmaten :input').attr('disabled', true); } } thanks in advance I have a jumpmenu that opens a shadowbox to show an image. It works fine in IE9, but in IE7 the shadowbox does not open and in the developer tools the error says "The value of the property 'MM_jumpMenu' is null or undefined, not a Function object". Being a noob I have no idea what the problem is. The coding in the <head> is; Code: <script type="text/javascript" src="shadowbox.js"></script> <script type="text/javascript"> Shadowbox.init(); </script> <script type="text/javascript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 if (selObj.selectedIndex == 0) return; Shadowbox.open({ content: selObj.options[selObj.selectedIndex].value, player: 'img', }); if (restore) selObj.selectedIndex=0; } function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </script> And in the <body> is; Code: <div id="apDiv2"> <form name="form1" id="form1"> <select name="Tema Demo" onchange="MM_jumpMenu('parent',this,0)"> <option value="Select Campsite" selected="selected">Select Campsite</option> <option value="/images/stories/campsite_images/Site (1)/1.jpg">Site 1</option> <option value="/images/stories/campsite_images/Site (3)/3.jpg">Site 3</option> </select> </form> </div> There are more options than this but I reduced them down for convenience. Any help would be greatly appreciated. Many thanks, Keith. Hello, I am learning some javascript and was testing this code from this site: Code: <script type='text/javascript'> function lengthRestriction(elem, min, max){ var uInput = elem.value; if(uInput.length >= min && uInput.length <= max){ return true; }else{ alert("Please enter between " +min+ " and " +max+ " characters"); elem.focus(); return false; } } </script> <form> Username(6-8 characters): <input type='text' id='restrict'/> <input type='button' onclick="lengthRestriction(document.getElementById('restrict'), 6, 8)" value='Check Field' /> </form> It only works when I click the "Check Field" button. It does not work when I hit "Enter" button on my keyboard, while it does on that site. Can anyone give me some idea what's going on? How can this be solved? Thanks for your help Hi, currently we are using IE 7 in that for showing submenu we are using the following code but it is not working in google chrome and firefox..basically it is a seperate .js file where functions are stored Code : Code: if( typeof ( gCSSList ) == 'undefined' || gCSSList == null ) var gCSSList= new Array();gCSSList[1]= Array('MENU_BLOCK_1','MENU_ITEM_1','MENU_ITEM_HL_1','MENU_ITEM_SL_1','MENU_ITEM_COL_LEFT_1','MENU_ITEM_COL_LEFT_HL_1','MENU_ITEM_COL_LEFT_SL_1','MENU_ITEM_COL_RIGHT_1','MENU_ITEM_COL_RIGHT_HL_1','MENU_ITEM_COL_RIGHT_SL_1','MENU_ITEM_HEADING_1','SUBMENU_BLOCK_1'); var gMainmenuFrm = 'left'; var gSubmenuFrm = 'right'; if( typeof ( gTimer ) == 'undefined' || gTimer == null ) var gTimer = new Array(); if( typeof ( HLItemList ) == 'undefined' || HLItemList == null ) var HLItemList = new Array(); if( typeof ( MenuList ) == 'undefined' || MenuList == null ) var MenuList = new Array(); function vMenu_AddtoHLList ( pCtrlId, pItemId ) { if( typeof ( HLItemList[pCtrlId] ) == 'undefined' || HLItemList[pCtrlId] == null ) HLItemList[pCtrlId] = pItemId+ ','; else HLItemList[pCtrlId] = HLItemList[pCtrlId] + pItemId+ ','; } function vMenu_AddtoMenuList ( pCtrlId, pMenuID ) { if( typeof ( MenuList[pCtrlId] ) == 'undefined' || MenuList[pCtrlId] == null ) MenuList[pCtrlId] = pMenuID + ','; else MenuList[pCtrlId] = MenuList[pCtrlId] + pMenuID + ','; } function vMenu_HideSubmenu ( pCtrlId, pMenuLevel ) { try { var MenuStr = new String(); objFrm = window.parent.frames(gSubmenuFrm); if( typeof ( MenuList[pCtrlId] ) == 'undefined' || MenuList[pCtrlId] == null ) return; MenuStr = MenuList[pCtrlId]; MenuArr = MenuStr.split(','); for( i=0; i < ( MenuArr.length - 1 ); i++ ) { MenuIds = MenuArr[i].split('_'); if( MenuIds[2] > pMenuLevel ) { object = objFrm.document.getElementById(MenuArr[i]); object.style.visibility = "hidden"; objFrm.document.getElementById('IF_'+object.id).style.visibility="hidden"; MenuStr = MenuStr.replace(MenuArr[i]+',',''); } } MenuList[pCtrlId] = MenuStr; } catch(e) { } } function vMenu_UnHilightItems ( pCtrlId, pLevel ) { objFrm = window.parent.frames(gSubmenuFrm); var ItemStr = new String(); ItemStr = HLItemList[pCtrlId]; if( typeof ( HLItemList[pCtrlId] ) == 'undefined' || HLItemList[pCtrlId] == null ) return; ItemArr = ItemStr.split(','); for( i=0; i < ( ItemArr.length - 1 ); i++ ) { ItemIds = ItemArr[i].split('_'); if(ItemIds[2] >= pLevel ) { if( ItemIds[2] == 1 ) { objmfr = window.parent.frames(gMainmenuFrm); object = objmfr.document.getElementById(ItemArr[i]); object.className = gCSSList[pCtrlId][1]; objmfr.document.getElementById(object.id+'_1').className = gCSSList[pCtrlId][4]; objmfr.document.getElementById(object.id+'_2').className = gCSSList[pCtrlId][7]; } // case : Item will be on submenu frame, use submenu frame reference to unhighlight item else { object = objFrm.document.getElementById(ItemArr[i]); object.className = gCSSList[pCtrlId][1]; objFrm.document.getElementById(object.id+'_1').className = gCSSList[pCtrlId][4]; objFrm.document.getElementById(object.id+'_2').className = gCSSList[pCtrlId][7]; } ItemStr = ItemStr.replace(ItemArr[i]+',',''); } } HLItemList[pCtrlId] = ItemStr; } function vMenu_HighlightItems ( pCtrlId, pEventItemId, EventFrm ) { objFrm = window.parent.frames(EventFrm); objFrm.document.getElementById(pEventItemId).className = gCSSList[pCtrlId][2]; objFrm.document.getElementById(pEventItemId+'_1').className = gCSSList[pCtrlId][5]; objFrm.document.getElementById(pEventItemId+'_2').className = gCSSList[pCtrlId][8]; } function vMenu_MenuItem_OnClick ( pTargetPage, pTargetType, pEventItem, pTargetFeatures, pReplace ) { var EventItemId = pEventItem.id; var IDs = EventItemId.split('_'); var CtrlId = new Number(IDs[1]); vMenu_HideSubmenu( CtrlId, 0 ); vMenu_UnHilightItems( CtrlId, 0 ); window.open( pTargetPage, pTargetType, pTargetFeatures, pReplace ); } item function vMenu_MenuItem_OnMouseOut ( pEventItem ) { var EventItemId = pEventItem.id; var IDs = EventItemId.split('_'); var CtrlId = new Number(IDs[1]); var Level = new Number(IDs[2]); vMenu_setMenuTimer ( CtrlId ); } function vMenu_MenuItem_OnMouseOver ( pEventItem ) { var EventItemId = pEventItem.id; var EventFrm = window.name; // split item id, to get detail about item var IDs = EventItemId.split('_'); var CtrlId = new Number(IDs[1]); var Level = new Number(IDs[2]); var ItemType = new Number(IDs[3]); var ItemIndex = new Number(IDs[4]); vMenu_clearMenuTimer ( CtrlId ); if( ( ItemType == 1 ) || ( ItemType == 4 ) ) return; vMenu_HideSubmenu ( CtrlId, Level ); vMenu_UnHilightItems( CtrlId, Level ); if( ItemType == 3 ) { MenuId = 'MNU_' + CtrlId + '_' + (Level+1) + '_' + ItemIndex; vMenu_ShowSubmenu ( EventItemId, MenuId ); vMenu_AddtoMenuList ( CtrlId, MenuId ); } vMenu_HighlightItems ( CtrlId, EventItemId, EventFrm ); vMenu_AddtoHLList ( CtrlId, EventItemId ); } function vMenu_ShowSubmenu ( pEventItemId, pMenuID ) { try { var IDs = pEventItemId.split('_'); var Level = new Number(IDs[2]); var SFrm; if ( Level == 1 ) { SFrm = window.name; objectfrm = window.parent.self; } else { SFrm = gSubmenuFrm; objectfrm = window.parent.frames(SFrm); } objtgtfrm = window.parent.frames(gSubmenuFrm); windowHeight = vMenu_GetWindowHeight ( SFrm ); windowYOffset = vMenu_GetWindowYOffset ( SFrm ); TopVal = vMenu_GetObjectTop ( pEventItemId, SFrm ); object = objtgtfrm.document.getElementById ( pMenuID ); tMenuHeight = object.offsetHeight; if ( Level == 1 ) { windowSubHeight = vMenu_GetWindowHeight ( gSubmenuFrm ); TopVal = TopVal - windowYOffset; windowSubYOffset = vMenu_GetWindowYOffset ( gSubmenuFrm ); TopVal = TopVal + windowSubYOffset; if ( ( TopVal + tMenuHeight ) > ( windowSubHeight + windowSubYOffset ) ) { TopVal = windowSubHeight + windowSubYOffset - tMenuHeight; if(TopVal < 0) TopVal = 0; } } else { if ( ( TopVal + tMenuHeight ) > ( windowHeight + windowYOffset ) ) { TopVal = windowHeight + windowYOffset - tMenuHeight; if(TopVal < 0) TopVal = 0; } } windowXOffset = vMenu_GetWindowXOffset ( gSubmenuFrm ); if ( Level == 1 ) { LeftVal = windowXOffset; } / else { windowWidth = vMenu_GetWindowWidth ( gSubmenuFrm ); LeftVal = vMenu_GetObjectLeft ( pEventItemId, gSubmenuFrm ); object = objectfrm.document.getElementById ( pEventItemId ); ParentWidth = object.offsetWidth; object = objtgtfrm.document.getElementById ( pMenuID ); tMenuWidth = object.offsetWidth; LeftVal = ParentWidth + LeftVal; if (LeftVal + tMenuWidth > windowWidth + windowXOffset) { LeftVal = LeftVal-ParentWidth-tMenuWidth; // case : calculated left is out of window area, set left to zero if(LeftVal<0) LeftVal = 0; } } // set left and top of menu object(table) object.style.left = LeftVal; object.style.top = TopVal; // set visibility of menu object to true object.style.visibility = "visible"; // set iframe position and dimension in such a way that it is displayed // at the same location and of the same dimention object_if = objtgtfrm.document.getElementById('IF_'+object.id); object_if.style.width = object.offsetWidth; object_if.style.height = object.offsetHeight; object_if.style.top = object.style.top; object_if.style.left = object.style.left; // set visibility of iframe related to menu object_if.style.visibility = "visible"; } catch (e) { // debug // alert ('exception:'+e); } } // function determines width of specified frame window // ???? Unsure which condition gives value under which scenario. function vMenu_GetWindowWidth ( pFrm ) { var value = 0; objectfrm = window.parent.frames(pFrm); if ( objectfrm.document.documentElement && objectfrm.document.documentElement.clientWidth ) { value = objectfrm.document.documentElement.clientWidth; } else if ( objectfrm.document.body ) { value = objectfrm.document.body.clientWidth; } if ( isNaN ( value ) ) { value = top.innerWidth; } return (value); } // function determines height of the specified frame window // ???? Unsure which condition gives value under which scenario function vMenu_GetWindowHeight ( pFrm ) { var value = 0; objectfrm = window.parent.frames(pFrm); if ( objectfrm.document.documentElement && objectfrm.document.documentElement.clientHeight ) { value = objectfrm.document.documentElement.clientHeight; } else if ( objectfrm.document.body ) { value = objectfrm.document.body.clientHeight; } if ( isNaN ( value ) ) { value = top.innerHeight; } return (value); } // function that determines verticle offset of specified frame window (based on verticle scroll position) // ???? Unsure which condition gives value under which scenario function vMenu_GetWindowXOffset ( pFrm ) { var value = 0; objectfrm = window.parent.frames(pFrm); if ( objectfrm.document.documentElement && objectfrm.document.documentElement.scrollLeft ) { value = objectfrm.document.documentElement.scrollLeft; } else if ( objectfrm.document.body ) { value = objectfrm.document.body.scrollLeft; } return (value); } // function that determines horizontal offset of specified frame window (based on verticle scroll position) // ???? Unsure which condition gives value under which scenario function vMenu_GetWindowYOffset ( pFrm ) { var value = 0; objectfrm = window.parent.frames(pFrm); if ( objectfrm.document.documentElement && objectfrm.document.documentElement.scrollTop ) { value = objectfrm.document.documentElement.scrollTop; } else if ( objectfrm.document.body ) { value = objectfrm.document.body.scrollTop; } return (value); } // calculate Left position of given object from left of the document function vMenu_GetObjectLeft ( pObjectName, pFrm ) { var value = 0; objectfrm = window.parent.frames(pFrm); object = objectfrm.document.all(pObjectName); // Loopthru parents to calculate left value // until parent is Body or does not have parent container while ( object.tagName != "BODY" && object.offsetParent ) { // retrives reference to the container object of given object object = object.offsetParent; value += object.offsetLeft; } return (value); } // calculates Top position of given object from tope of the document function vMenu_GetObjectTop ( pObjectName, pFrm ) { var value = 0; objectfrm = window.parent.frames(pFrm); object = objectfrm.document.all(pObjectName); value = object.offsetTop; // Loopthru parents to calculate top value // until parent is Body or does not have parent container while ( object.tagName != "BODY" && object.offsetParent ) { // retrives reference to the container object of given object object = object.offsetParent; value += object.offsetTop; } return (value); } // this function sets timer, and Function to be executed after timer time out // settimeout function returns reference, whcih can be used to clear timer // this function is called on mouse out of Menu item, so that Menu is closed automatically after some time function vMenu_setMenuTimer ( pCtrlId ) { gTimer[pCtrlId] = setTimeout('vMenu_HideSubmenu('+pCtrlId+',0);vMenu_UnHilightItems('+pCtrlId+',0);', 1000); } // this function clears timer using timer reference available, called onmouse over of menu item function vMenu_clearMenuTimer ( pCtrlId ) { clearTimeout(gTimer[pCtrlId]); } I write javascript for image slide show. Code: var mygallery=new fadeSlideShow({ wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow dimensions: [380, 469], //width/height of gallery in pixels. Should reflect dimensions of largest image imagearray: [ <?php $q2 = mysql_query("select * from home_flash"); $i = 0; while($res = mysql_fetch_array($q2)) { $image[$i] = $res[1]; $text[$i] = $res[2]; $str = "['images/fla/".$image[$i]."','','','".$text[$i]."'],"; echo $str; $i++; } ?> //<--no trailing comma after very last image element! ], displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false}, persist: false, //remember last viewed slide and recall within same session? fadeduration: 500, //transition duration (milliseconds) descreveal: "always", togglerid: "" }) In IE I got an error Quote: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2) Timestamp: Sat, 20 Mar 2010 06:22:10 UTC Message: 'imagearray[...].0' is null or not an object Line: 37 Char: 3 Code: 0 If you have solution for thi, then please help with it! Thanks for your precious time. Cheers!! Hey all, great forum! I am wanting to change the CSS properties for a webapp.. The default instance is when the webapp is launched from a safari browser. The part I have trouble with, is defining how to show different CSS when the webapp is launched from the homescreen of a mobile device. Here is the code I am trying, but have no luck: Quote: <script type="text/javascript"> if (window.navigator.standalone == true) { //alert('homescreen'); $('body > #footer').css({bottom: '0px !important'}); $('body > #wrapper').css({bottom: '0px !important'}); } </script> wat's good.I tried the script at http://www.javascriptkit.com/script/script2/dropdownpanel.shtml but it's not working the right way.I followed what the tut suggests but still issue over issue.when I click on panel button it goes back but not on the page content.i don't know if need to change something in the css file or the js file. Appreciate your help! Experts, I'm banging my head against the wall with this one. http://www.dev.sgpconsulting.co.uk/weprintstuff The large header banner on the homepage is a Javascript slideshow used to generate interest in individual products. It works fine in IE, but not at all in FF or Chrome, and I can't figure out why. I'd really appreciate any advice anyone can offer. Steve Hello i need help to find errors in that javascript i am trying to find the error but i could not i really need your help please here the javascript code <html> <head> <title>Textbox and submission button</title> <script language = "Javascript"> function display_messages() { if (var textentered = " message1") { alert (" This is message 1"); } else if (var textentered = " message2") { alert (" This is message 2"); } else if (var textentered = " message3") { alert (" This is message 3"); } else if (var textentered = " message4") { alert (" This is message 4"); } else if (var textentered = " message5") { alert (" This is message 5"); } else alert (" message name is not found"); } } var textentered = document.form1.textbox1.value var messages = new Array(5); alert(messages[0][1] = ["message1", "This is message 1"]); alert(messages[1][2] = ["message2", "This is message 2"]); alert(messages[2][3] = ["message3", "This is message 3"]); alert(messages[3][4] = ["message4", "This is message 4"]); alert(messages[4][5] = ["message5", "This is message 5"]); onclick="displayMessage();"; </head> </script> <body onclick="alert(document.form1.textbox1.button);"> <form name="form1"> <table border="0" cellspacing="0" cellpadding="5" width="60%" align="center"> <tr> <td>Textbox 1:</td> <td><input type="text" name="textbox1" value="" /> <input type="button" name="button" value="Submit" onclick="function_display_message();"/> </td> </tr> </table> </form> </body> </html> Can someone help me please I havent even declared x,y and z as variables! Code: x=10; y=20; z = x+y; document.getElementById('good').innerHTML=z; I am getting so confused... since the time i started learning JS i thought declaring variables (var x,y,z was real important! Hi, I am trying to get a javascript if else function to initiate during the page onload. In IE the if command doesn't work if I add an else command (the command shown though the session value is set to comply with the if command). While when using Firefox neither works. Any help would be fantastic. Code: <?php session_start(); $_SESSION['ID']='x'; ?> <html> <head> <script type="text/javascript"> if ($_SESSION['ID']=='x'){ function loadXMLDoc() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","ajax_info.txt",true); xmlhttp.send(); } } else{ function loadXMLDoc() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","ajax_mine.txt",true); xmlhttp.send(); } } </script> </head> <body onload="loadXMLDoc()"> <div id="myDiv"><h2>Page Loading</h2></div> </body> </html> The ajax_info.txt file and the ajax_mine.txt file both show basic information only. |