JavaScript - Javascript Only Half Working
Hi
This is the script i am using and at the moment it only makes the greyscale image but does not fade to colour on mouseover. Here is the site of the original code:http://webdesignerwall.com/demo/html5-grayscale/ Just Viewsource for the code. I am also trying to integrate this into my website and have no idea how to set the target image. Can anyone help with this please? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>HTML5 & jQuery - Grayscale Image Hover</title> <style type="text/css"> body { background: #fff; color: #000; font: 14px/140% Arial, Helvetica, sans-serif; margin: 40px 0; } a { text-decoration: none; color: #86AEBB; } img { border: none; } h2 { font: bold 14px/110% Arial, Helvetica, sans-serif; margin: 0 0 30px; padding: 0 0 20px; color: #999; border-bottom: solid 1px #ccc; clear: both; } h3 { font: bold 16px/120% Arial, Helvetica, sans-serif; margin: 0; } #pagewrap { width: 948px; margin: 0 auto; } .item { width: 296px; margin: 0 0 30px 30px; float: left; } .item.first { clear: left; margin-left: 0; } .item img { opacity:0; } </style> <script src="jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> // $(".item img").css({"display":"none"); // On window load. This waits until images have loaded which is essential $(window).load(function(){ // Fade in images so there isn't a color "pop" document load and then on window load $(".item img").animate({opacity:1},500); // clone image $('.item img').each(function(){ var el = $(this); el.css({"position":"absolute"}).wrap("<div class='img_wrapper' style='display: inline-block'>").clone().addClass('img_grayscale').css({"position":"absolute","z-index":"998","opacity":"0"}).insertBefore(el).queue(function(){ var el = $(this); el.parent().css({"width":this.width,"height":this.height}); el.dequeue(); }); this.src = grayscale(this.src); }); // Fade image $('.item img').mouseover(function(){ $(this).parent().find('img:first').stop().animate({opacity:1}, 1000); }) $('.img_grayscale').mouseout(function(){ $(this).stop().animate({opacity:0}, 1000); }); }); // Grayscale w canvas method function grayscale(src){ var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); var imgObj = new Image(); imgObj.src = src; canvas.width = imgObj.width; canvas.height = imgObj.height; ctx.drawImage(imgObj, 0, 0); var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height); for(var y = 0; y < imgPixels.height; y++){ for(var x = 0; x < imgPixels.width; x++){ var i = (y * 4) * imgPixels.width + x * 4; var avg = (imgPixels.data[i] + imgPixels.data[i + 1] + imgPixels.data[i + 2]) / 3; imgPixels.data[i] = avg; imgPixels.data[i + 1] = avg; imgPixels.data[i + 2] = avg; } } ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width, imgPixels.height); return canvas.toDataURL(); } </script> </head> <body> <div id="pagewrap"> <h1>HTML5 & jQuery Grayscale Demo</h1> <h2>Tutorial by <a href="http://www.webdesignerwall.com">Web Designer Wall</a> (<a href="http://www.webdesignerwall.com/tutorials/html5-grayscale-image-hover/">read article</a>). Coding by <a href="http://darcyclarke.me">Darcy Clarke</a>.</h2> <div class="item first"> <a href='http://127.0.0.1/web/Msapcalcmainsite/Mainpage.html'><img src="http://127.0.0.1/web/Msapcalcmainsite/Numbers.png"></a> <h3>Themify</h3> </div> <div class="item"> <a href="http://icondock.com"><img src="http://127.0.0.1/web/Msapcalcmainsite/Numbers.png"></a> <h3>IconDock</h3> </div> </div> </body> </html> Similar TutorialsHey guys, I'm trying to make a function that will display certain elements when a paragraph is clicked. As of right now, the function is called, and only the first line gets executed properly. The rest don't work. $postCount is a counter variable setup by a for loop that it is in. When I view source, it is working properly. Code: function newComment".$postCount."() { document.getElementById('postComment$postCount').style.display = 'none'; document.getElementById('newCommentProfilePicture$postCount').style.display = ''; document.getElementById('commentBox$postCount').style.display = ''; document.getElementById('submitComment$postCount').style.display = ''; document.getElementById('addCommentContainer$postCount').style.display = ''; document.getElementById('commentBox$postCount').rows = '3'; } PHP Code: echo "<div class='viewComment' id='viewCommentButton".$postCount."'> <div class='leftCommentControl'>"; if ($numComments > 0) { echo "<p class='viewCommentLink' id='viewCommentLink".$postCount."' onclick='showComment".$postCount."()' onmouseover=\"this.style.textDecoration='underline'; this.style.cursor='pointer'\" onmouseout=this.style.textDecoration='none'> View ".$numComments." Hidden Comments!</p>"; } echo "</div> <div class='rightCommentControl'> <p class='postComment' id='postComment".$postCount."' onclick='newComment".$postCount."()' onmouseover=\"this.style.textDecoration='underline'; this.style.cursor='pointer'\" onmouseout=this.style.textDecoration='none'>Add Comment</p> </div> </div> <div class='addCommentContainer' id='addCommentContainer".$postCount."' style='display: none'> <form action='processComment.php?userid=".$_SESSION['userid']."&postid=".$row['postid']."&sentFrom=$currentPage' method='POST'> <img class='newCommentProfilePicture id='newCommentProfilePicture".$postCount."' src='uploadPic/mini".$_SESSION['picture']."' style='display: none'></img> <textarea id='commentBox".$postCount."' class='commentTextArea' name='commentBox' rows='1' cols='49' onfocus='newComment".$postCount."()'></textarea> <input type='submit' class='button' id='submitComment".$postCount."' name='submit' ALT='Submit button' value='Comment' style='display: none'> </form> </div> </div> </div>"; 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! Hi. I am having trouble getting my code to validate for my speed/distance calculator. I have 2 input prompts: 1 for hours and 1 for minutes. The issue is I can put a number for hours (e.g 7) and W for minutes and the result will display distance is NaN, whereas I am expecting it to alert user to input a valid number. The same issue applies if I switch the order of isNan(hours) and isNaN(mins) If you have even the slightest idea of what I have done wrong, or what I am missing I will truly appreciate the input. Thanks! Code: <html> <head> <title>Sound Travel Calculator</title> <script type="text/javascript"> // ?????????????????????????????????????????????????????????????????????????????????????????????????????????????? // the program works pretty well except if i put, lets say 7 hours and w mins then it will say the distance traveled is NaN. but it should be re-prompting to enter hours and mins. It doesn't matter if I switch the order of isNan(hours) and isNaN(mins) // ?????????????????????????????????????????????????????????????????????????????????????????????????????????????? // Setting our variables based on user input var hours = 0; var mins = 0; var m_per_secs = 340; alert("Speed of Sound \n\nAt Sea Level Sound Travels At 340 Metres Per Second \n\nIf You Would Like To Know How many Kilometres sound Will Travel In A Given Time, Click OK"); hours = prompt("Please Enter Hours (If less than 1 hour, just type 0)"); mins = prompt("Please Enter Minutes"); // Validating input for a number less than zero or an not a number while ((isNaN(hours)) || (isNaN(mins)) && (hours < 0) || (mins < 0)) { alert("Please enter a numeric value, zero or greater"); hours = prompt("Please Enter Hours (If less than 1 hour, just type 0)"); mins = prompt("Please Enter Minutes"); } // if there is no input, the value is set to zero if (hours =="") { hours = 0; } if (mins =="") { mins = 0; } // Calculations dist = (((parseFloat(hours)) * 60 * 60) + (parseFloat(mins * 60)) * parseFloat(m_per_secs) / 1000) // Output our calculation alert("The Distance of Sound Travelled is " + (dist) + " Kilometres"); //end program </script> </head> <body> </body> </html> 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 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 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 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 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. 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 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 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> 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]); } 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! 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 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 Hi, This problem has completely stumped me, was hoping from a bit of advice. I have used the code of my affiliate software to show my company logo. This code works in Firefox, but for some reason doesn't work in IE. The company who own the affiliate software have never seen this problem before and have been unable to assist. Not sure if it's a server problem? To see the problem have a look at logo at the top of my test website in firefox then IE. http://www.nctshop.co.uk/staging/ Here is a snippet of the code below. It is the line where it links to nctshopaffiliate which is where the problem lies. Thanks! Adrian Code: <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td class="topnav1bgcolor"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><a href="../default.asp"><script language="JavaScript" type="text/javascript" src="http://www.nctshopaffiliate.co.uk/display.php?token=logo" alt="NCTSHOP" width="650" height="89" border="0"/></script></a></td> <td align="right" valign="top"> <table width="223" border="0" cellpadding="0" cellspacing="0"> <tr><td height="5" colspan="5"><img src="images/clear.gif" alt="" style="width:1;height:1;border:0"></td></tr> <tr><td colspan="5"> </td></tr> <tr><td height="25" colspan="5"><img src="images/clear.gif" alt="" style="width:1;height:1;border:0"></td></tr> <tr> <td class="plaintext"><a title="View Basket" href="basket.asp"><img src="images/newcart_Img.gif" alt="View Basket" style="width:23;height:12;border:0"></a></td> <td><img src="images/clear.gif" alt="" style="width:5;height:1;border:0"></td> <td style="background-image:url(images/bkg_cartinfo.gif);height:21"> <table width="200" border="0" cellpadding="0" cellspacing="0" > <tr> <td class="plaintext" align="center"><a title="View Basket" href="basket.asp"><span class="plaintext"><u>Items</u></span></a> <%=session("SL_BasketCount")%> | Sub Total <%=formatcurrency(session("SL_BasketSubTotal"))%></td> </tr> </table> </td> <td> </td> <td><a class="topnav1" title="Checkout" href="<%=session("secureurl")%>custinfo.asp" ><u>Checkout</u></a></td> </tr> </table> </td> <td style="width:10"><img src="images/clear.gif" alt="" style="width:1;height:1;border:0"></td> </tr> </table> </td> </tr> </table> I am having trouble with javascript code that is inside an iframe. I am trying to simulate the w3School's tryit. I have tried setting the content of the iframe two different ways and got two different results. This is example code for what I want the iframe's content to be <html> <head> <script type="text/javascript"> function coordinates(event) { x=event.screenX; y=event.screenY; alert("X=" x " Y=" y); } </script> </head> <body onmousedown="coordinates(event)"> <p> Click somewhere in the document. An alert box will alert the x and y coordinates of the cursor, relative to the screen. </p> </body> </html> The first way which was successful (but not what i want) is to save the example code as example.html and set the src property of the iframe to that document. Everything works fine including the mouseEvent. The second way displays the example.html in the iframe as it should but it seems to be ignoring the javascript. This is how I set the iframe content: I have the code stored in a database table. I use xmlHTTPRequest to bring grab the code and it is stored in a variable called responseText. Frome here I the following code sets the iframe content. r = document.getElementById("iframe"); Doc = r.contentWindow || r.contentDocument; if(Doc.document){ Doc = Doc.document; Doc.open(); Doc.write(responseText); Doc.close(); alert(Doc.documentElement.innerHTML); } If anyone can can help me understand why the javascript code doesn't work the second way I would greatly appreciate it. Hey everyone, I am new to this forums, and hope I can count on people here to help me when I need help with codes. Basically i'm building a proxy for personal use. The proxy is to do two things. 1): Go to any website I suggest (that part works already) 2): Change watever needs to be changed so I could use it at school (This is the part I need help with) The code is below, and I would appreciate anyone who could help me fix this: Code: <html> <script type = "Text/Javascript"> function Search_Web() { var data = document.getElementById('URL').value; window.location = data; } </script> <center> <h1><font color = green>Enter A Website</font></h1> <input type = "text" id = "URL" value = "" size = "50"> <input type = "Button" value = "Search Web" onClick = "Search_Web();"> </center> </html> This is suppose to execute "avalon" and it should move down the page once and "Books" should move with it, hidden behind it. I have read the code over and over and over and do not see any mistakes. HELP! Code: <title>Avalon Books</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <script src="scripts.js" type="text/javascript"></script> <script type="text/javascript"> function placeObjects() { placeIt("avalon",175,10); placeIt("books", 175,10); placeIt("ab",230,40); placeIt("fiction",5,5); placeIt("nfiction",475,5); hideIt("ab"); hideIt("fiction"); hideIt("nfiction"); moveAvalon(); } function moveAvalon() { var y=yCoord("avalon"); if (y <= 260) { shiftIt("avalon",0,10); shiftIt("books",0,10); setTimeout("moveAvalon()",30); } else { moveBooks(); } } function moveBooks() { var x=xCoord("books"); if (x <= 320) { shiftIt("books",10,0); setTimeout("moveBooks()",50); } else { //display the hidden images; } } </script> </head> <body onload="placeObjects()"> <div id="avalon"> AVALON </div> <div id="books"> BOOKS </div> <div id="ab"> <a href="#"> <img src="ab.jpg" alt="Click to enter store" /> </a> </div> <div id="fiction"> <img src="fiction.jpg" alt="" /><br /> <b>AB Sales Rank: #1<br /> Fiction</b><br /> <i>Before the Fall</i><br />Jeffrey Unwin </div> <div id="nfiction"> <img src="nfiction.jpg" alt="" /><br /> <b>AB Sales Rank: #1<br /> Nonfiction</b><br /> <i>Vietnam Memoirs</i><br />Gen. John Hartford </div> </body> </html> |