JavaScript - Javascript/json Onload Not Working
When I call my controller function template it should select the template name from database and find the matching image.png
Currently when I call the function from view via json it only displays no_image.png even though both links work. I have echoed and tested. For my controller it is CodeIgniter Based. How can I get my json script code work. It is calling URL fine. If image name does not match the $this->input->get('template') name should display no image. Codeigniter Controller Function Code: public function template() { $this->load->library('response'); if ($this->input->server('HTTPS')) { $server = HTTPS_SERVER; } else { $server = HTTP_SERVER; } if (is_file(FCPATH . '/image/' . 'templates/' . basename($this->input->get('template')) . '.png')) { $this->response->setOutput($server . 'image/templates/' . basename($this->input->get('template')) . '.png'); } else { $this->response->setOutput($server . 'image/no_image.jpg'); } } View Code: <div class="form-group"> <label class="col-sm-2 control-label" for="input-template"><?php echo $entry_template; ?></label> <div class="col-sm-10"> <select name="config_template" id="input-template" class="form-control"> <?php foreach ($templates as $template) { ?> <?php if ($template == $config_template) { ?> <option value="<?php echo $template; ?>" selected="selected"><?php echo $template; ?></option> <?php } else { ?> <option value="<?php echo $template; ?>"><?php echo $template; ?></option> <?php } ?> <?php } ?> </select> <br /> <img src="" alt="" id="template" class="img-thumbnail" /> </div> </div> </div><!-- / End Tab Website --> <div class="tab-pane" id="tab-local"> </div> <div class="tab-pane" id="tab-option">Option</div> <div class="tab-pane" id="tab-server">Server</div> </div> </form> </div> </div> </div> </div> <script type="text/javascript"><!-- $('select[name=\'config_template\']').on('change', function() { $.ajax({ url: 'http://localhost/codeigniter/admin/?c=website/&m=template&template=' + encodeURIComponent(this.value), dataType: 'html', beforeSend: function() { $('select[name=\'country_id\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>'); }, complete: function() { $('.fa-spin').remove(); }, success: function(html) { $('.fa-spin').remove(); $('#template').attr('src', html); }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }); $('select[name=\'config_template\']').trigger('change'); //--></script> Similar TutorialsHi, 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. i'm having a problem getting something called JavaScript Bitcoin Miner working in IE6+ the error i'm getting is: Line: 8 Char: 6 Error: 'JSON' is undefined Code: 0 URL: http://192.168.0.105/Bitcoin_Miner/index.html does anyone know how i can get this working? thanks. Attached is the source files. BTW... you'll need to instal XAMPP to get this working correctly on your local PC. But if there's a way all of the PHP can be converted to PHP, and Jquery can be cut out of the picture, it would be VERY helpful Hello Can anyone help with the following problem On the following page http://www.stroudskittles.co.uk/signingon.html I have a Body onload event (to load the chained Menu) and a windows.onload event (to load the IFrame Ticker) If I open the page in Internet explorer both scripts function; however in Firefox I'm having problems. The Chained Menu works, however the IFrame Ticker does not display. Both events ahave ben placed on the boady tag. Can anyone advise how I can get both to display in Firefox Can anyone Hello, I have a bit of javascript that automatically loads Shadowbox on load. It works perfectly in Firefox, Chrome but NOT IE. If I put a standard link to open Shadowbox does work in IE, so it's not the shadowbox, it's definitely the window.onload bit which isn't working. Here is my code. Code: <link rel="stylesheet" type="text/css" href="shadowbox/shadowbox.css"> <script type="text/javascript" src="shadowbox/shadowbox.js"></script> <!--this bit is for a link to open the Shadowbox from a link elsewhere on the page --> <script type="text/javascript"> Shadowbox.init({players:['swf']}); </script> <script type="text/javascript"> window.onload = function() { Shadowbox.open({ content: 'flash/flash002.swf', player: "swf", title: 'Open Shadowbox', width: 1200, height: 800, }); }; </script> This DOES work though, so I know it's not the Shadowbox with the issue Code: <a href="flash/flash002.swf" rel="shadowbox;height=800px;width=1200px">Open Shadowbox</a> Really appreciate your help! Nicola Firefox works a dream, but in IE, Google Chrome, Safari and Avant javascript does not run at all. Looking at the code it may be the body 'onload' that is not firing? Has anyone got any advise on this on how I might be able to fix it. the javascript Code: /* Script by FPMC at http://jsarchive.8m.com Submitted to JavaScript Kit (http://javascriptkit.com) For this and 400+ free scripts, visit http://javascriptkit.com */ src = ['../images/Intro_01.png', '../images/Intro_02.png', '../images/Intro_03.png', '../images/Intro_04.png', '../images/Intro_05.png', '../images/Intro_06.png']; //set image paths // url = ['http://freewarejava.com', 'http://javascriptkit.com', 'http://dynamicdrive.com', 'http://www.geocities.com']; //set corresponding urls duration = 3; //set duration for each image //Please do not edit below ads=[]; ct=0; function switchAd() { var n=(ct+1)%src.length; if (ads[n] && (ads[n].complete || ads[n].complete==null)) { document['Intro_Image'].src = ads[ct=n].src; } ads[n=(ct+1)%src.length] = new Image; ads[n].src = src[n]; setTimeout('switchAd()',duration*1000); } the body tag Code: <body onload="switchAd(this);"> the img tag Code: <img id="Intro_Image" src="images/Intro_01.png" alt="slideshow" style="width: 230px; border: 0;"> Hi I am new to javascript and designing websites as a whole. I have been playing around with a drag and drop java script from this site: http://www.redips.net/javascript/dra...table-content/ A switch content setting is currently available to check in a checklist: <input name="drop_option" type="radio" class="checkbox" title="Switch content" onclick="set_drop_option(this)" value="switch"/> I wan it to run without any checklist or button whatsoever just from the page load. I am not sure how I would do this. Any suggestions? Thank you Jonathan Hi, I need to use more than one javascripts that use onload event. Every time I try this only one from these scripts work correctly. How can I make these scripts work together? 1) Code: var kmrSimpleTabs = { sbContainerClass: "simpleTabs", sbNavClass: "simpleTabsNavigation", sbContentClass: "simpleTabsContent", sbCurrentNavClass: "current", sbCurrentTabClass: "currentTab", sbIdPrefix: "tabber", init: function(){ if(!document.getElementsByTagName) return false; if(!document.getElementById) return false; var containerDiv = document.getElementsByTagName("div"); for(var i=0; i<containerDiv.length; i++){ if (containerDiv[i].className == kmrSimpleTabs.sbContainerClass) { // assign a unique ID for this tab block and then grab it containerDiv[i].setAttribute("id",kmrSimpleTabs.sbIdPrefix+[i]); var containerDivId = containerDiv[i].getAttribute("id"); // Navigation var ul = containerDiv[i].getElementsByTagName("ul"); for(var j=0; j<ul.length; j++){ if (ul[j].className == kmrSimpleTabs.sbNavClass) { var a = ul[j].getElementsByTagName("a"); for(var k=0; k<a.length; k++){ a[k].setAttribute("id",containerDivId+"_a_"+k); // get current if(kmrSimpleTabs.readCookie('simpleTabsCookie')){ var cookieElements = kmrSimpleTabs.readCookie('simpleTabsCookie').split("_"); var curTabCont = cookieElements[1]; var curAnchor = cookieElements[2]; if(a[k].parentNode.parentNode.parentNode.getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont){ if(a[k].getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont+"_a_"+curAnchor){ a[k].className = kmrSimpleTabs.sbCurrentNavClass; } else { a[k].className = ""; } } else { a[0].className = kmrSimpleTabs.sbCurrentNavClass; } } else { a[0].className = kmrSimpleTabs.sbCurrentNavClass; } a[k].onclick = function(){ kmrSimpleTabs.setCurrent(this,'simpleTabsCookie'); return false; } } } } // Tab Content var div = containerDiv[i].getElementsByTagName("div"); var countDivs = 0; for(var l=0; l<div.length; l++){ if (div[l].className == kmrSimpleTabs.sbContentClass) { div[l].setAttribute("id",containerDivId+"_div_"+[countDivs]); if(kmrSimpleTabs.readCookie('simpleTabsCookie')){ var cookieElements = kmrSimpleTabs.readCookie('simpleTabsCookie').split("_"); var curTabCont = cookieElements[1]; var curAnchor = cookieElements[2]; if(div[l].parentNode.getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont){ if(div[l].getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont+"_div_"+curAnchor){ div[l].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; } else { div[l].className = kmrSimpleTabs.sbContentClass; } } else { div[0].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; } } else { div[0].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; } countDivs++; } } // End navigation and content block handling } } }, // Function to set the current tab setCurrent: function(elm,cookie){ this.eraseCookie(cookie); //get container ID var thisContainerID = elm.parentNode.parentNode.parentNode.getAttribute("id"); // get current anchor position var regExpAnchor = thisContainerID+"_a_"; var thisLinkPosition = elm.getAttribute("id").replace(regExpAnchor,""); // change to clicked anchor var otherLinks = elm.parentNode.parentNode.getElementsByTagName("a"); for(var n=0; n<otherLinks.length; n++){ otherLinks[n].className = ""; } elm.className = kmrSimpleTabs.sbCurrentNavClass; // change to associated div var otherDivs = document.getElementById(thisContainerID).getElementsByTagName("div"); var RegExpForContentClass = new RegExp(kmrSimpleTabs.sbContentClass); for(var i=0; i<otherDivs.length; i++){ if ( RegExpForContentClass.test(otherDivs[i].className) ) { otherDivs[i].className = kmrSimpleTabs.sbContentClass; } } document.getElementById(thisContainerID+"_div_"+thisLinkPosition).className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; // get Tabs container ID var RegExpForPrefix = new RegExp(kmrSimpleTabs.sbIdPrefix); var thisContainerPosition = thisContainerID.replace(RegExpForPrefix,""); // set cookie this.createCookie(cookie,'simpleTabsCookie_'+thisContainerPosition+'_'+thisLinkPosition,1); }, // Cookies createCookie: function(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }, readCookie: function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; }, eraseCookie: function(name) { this.createCookie(name,"",-1); }, // Loader addLoadEvent: function(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } // END }; // Load SimpleTabs kmrSimpleTabs.addLoadEvent(kmrSimpleTabs.init); 2) Code: function hideMessage() { document.getElementById("thanks").style.display="none"; } function startTimer() { var tim = window.setTimeout("hideMessage()", 5000); // 5000 milliseconds = 5 seconds } 3) Code: var ids=new Array(); function QAinit(){ if(document.getElementById){ var tids=document.getElementsByTagName('div'); for(i=0;i<tids.length;i++)if(tids[i].className=="question")ids[ids.length]=tids[i]; for(i=0;i<ids.length;i++)ids[i].onmouseup=setstate; }} function setstate(){ for(i=0;i<ids.length;i++){ if(ids[i]==this){ var d=this.parentNode.getElementsByTagName('div')[1]; if(d.style.display=="block")d.style.display="none"; else d.style.display="block"; }}} function expandall(){ if(document.getElementById){ for(i=0;i<ids.length;i++)ids[i].parentNode.getElementsByTagName('div')[1].style.display="block"; }} function collapseall(){ if(document.getElementById){ for(i=0;i<ids.length;i++)ids[i].parentNode.getElementsByTagName('div')[1].style.display="none"; }} window.onload=QAinit; Can anyone please help? Hello can please help convert this real simple slide show so that is plays immediately on page load. Thank you PHP Code: var ImgNum = 0; var ImgLength = NewImg.length - 1; //Time delay between Slides in milliseconds var delay = 7000; var lock = false; var run; function chgImg(direction) { if (document.images) { ImgNum = ImgNum + direction; if (ImgNum > ImgLength) { ImgNum = 0; } if (ImgNum < 0) { ImgNum = ImgLength; } document.slideshow.src = NewImg[ImgNum]; } } function auto() { if (lock == true) { lock = false; window.clearInterval(run); } else if (lock == false) { lock = true; run = setInterval("chgImg(1)", delay); } } I have the following javascript function: [ function addNewWindowEvent(evType, fn) { if (window.addEventListener) { this.addEventListener("load", fn, false); return true; } else if (window.attachEvent) { var onload = "onload" this.attachEvent(onload, fn); return true; } else { return false; } } ] which is giving me a an exception every time a page on our site loads. The actual exception in firefox is this: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: https://cms-dev.stchas.edu/global/js/hdvscripts.js :: addNewWindowEvent :: line 5" data: no] and I'm not sure exactly what it's complaining about. I'm relatively new to javascript so diagnosing and fixing this problem has me quite puzzled, and so far I have been unable to find anything helpful when I try and google for information on this. I would appreciate any help or suggestions. Thanks. henryv I have a very large json file, and inside of that json file is an array. I would like to use JavaScript to take that json as an argument, parse through the json and only take certain elements from it and put it into a new json file, below is an example of what I mean: Code: { "contextType": "Account", "preferences": null, "custodianCode": null, "data": [{ "id": "0", "account": "11111111", "field2": true, "field3": false, "field4": "BROK", "field5": "Broker", "field6": "1", "field7": "Cash" },{ "id": "1", "account": "222222222", "field2": true, "field3": false, "field4": "BROK", "field5": "Broker", "field6": "1", "field7": "Cash" }] } And I want to pull from that and get something like this as a new json Code: { "newArray": [{ "id": "0", "account": "11111111", "field2": true, "field3": false, "field4": "BROK", "field6": "1" },{ "id": "0", "account": "222222222", "field2": true, "field3": false, "field4": "BROK", "field6": "1" }] } Also the file is local to my computer and can be outputted locally as well, I am trying to use node.js and JavaScript this is what I have so far Code: var json = require('./simple.json'); var keeperFields = ["id", "account", "field2", "field3", "field4", "field6"]; var newJSON = {newArray: [] }; var i; var fields; for (i = 0; i < keeperFields.length; i++) { for (fields in json) { if (json.hasOwnProperty(keeperFields[i])) { newJSON.newArray.push(keeperFields[i]); } } } console.log(newJSON); This is just a small example the real json file is huge with thousands of lines. Any help or suggestions are appreciated! This current solution is giving me a console log of { newArray: []} instead of the expected result above 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 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!! 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]); } 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> 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 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. 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 |