JavaScript - Why Does Adding A Comment Tag Hide The Js If The Browser Does Not Support Js
Why does a comment tag hide the havascript if the browser does not support javascript? I thought comment tags were for comments not to hide things...
Similar TutorialsHey guys. I am using a javascript slideshow called fadeshow. (Main code below). I am wondering if there is a way to have thumbnail support, so I could allow the users to click on a thumbnail and have fadeshow go to that photo in the array. I have gotten a next / previous button working but also would like to add thumbnails. How would I write an a href link to specify an image in the array? Can this be done? Code: <script type="text/javascript"> var mygallery2=new fadeSlideShow({ wrapperid: "fadeshow2", //ID of blank DIV on page to house Slideshow dimensions: [1000, 665], //width/height of gallery in pixels. Should reflect dimensions of largest image imagearray: [ ["images/1m.jpg"], ["images/2m.jpg"], ["images/3m.jpg"] ], displaymode: {type:'manual', pause:2500, cycles:0, wraparound:true}, persist: false, //remember last viewed slide and recall within same session? fadeduration: 500, //transition duration (milliseconds) descreveal: "always", togglerid: "fadeshow2toggler" }) </script> <div id="fadeshow2toggler"> <a href="#" class="next"><div id="fadeshow2"></div></a><!--allows clicking the photo for next--> <a href="#" class="prev">Previous</a> <a href="#" class="next">Next Image</a> ( <span class="status"></span> )</span> </div><!--end fadeshow2toggler--> <!--thumbnails i would like to work--> <a href= # ><img src="images/thumbnail1.jpg"></a> <a href= # ><img src="images/thumbnail2.jpg"></a> <a href= # ><img src="images/thumbnail3.jpg"></a> Any advice appreciated! Hi All, i have an auto suggest function which suggests results to the user from my db. now if i click on one of the suggestions with the mouse it redirects to the relivant url which is stored in the db, however if i use the arrow keys and select a suggestion with the enter key nothing happens can anyone please help me to get this working so that if i press enter when a suggestion is selected it goes to that stores url? thanks and my index.php code PHP Code: <div class="main"> <form id="test" name="form1" method="post" action=""> <div id="holder"> <input type="text" id="keyword" tabindex="0"><img src="images/loading.gif" id="loading"> </div> <div id="ajax_response"></div> </div></form> here is my ajax_server.php page code PHP Code: <?php include("config.php"); $keyword = $_POST['data']; $sql = "select storeName,storeLink from ".$db_table." where ".$db_column." like '".$keyword."%' limit 0,20"; //$sql = "select name from ".$db_table.""; $result = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($result)) { echo '<ul class="list">'; while($row = mysql_fetch_array($result)) { $str = strtolower($row['storeName']); $link = $row['storeLink']; $start = strpos($str,$keyword); $end = similar_text($str,$keyword); $last = substr($str,$end,strlen($str)); $first = substr($str,$start,$end); $final = '<span class="bold">'.$first.'</span>'.$last; echo '<li><a href="'.$link.'">'.$final.'</a></li>'; } echo "</ul>"; } else echo 0; ?> and my script.js file Code: $(document).ready(function(){ $(document).click(function(){ $("#ajax_response").fadeOut('slow'); }); $("#keyword").focus(); var offset = $("#keyword").offset(); var width = $("#keyword").width()-2; $("#ajax_response").css("left",offset.left); $("#ajax_response").css("width",width); $("#keyword").keyup(function(event){ //alert(event.keyCode); var keyword = $("#keyword").val(); if(keyword.length) { if(event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 13) { $("#loading").css("visibility","visible"); $.ajax({ type: "POST", url: "ajax_server.php", data: "data="+keyword, success: function(msg){ if(msg != 0) $("#ajax_response").fadeIn("slow").html(msg); else { $("#ajax_response").fadeIn("slow"); $("#ajax_response").html('<div style="text-align:left;">No Matches Found</div>'); } $("#loading").css("visibility","hidden"); } }); } else { switch (event.keyCode) { case 40: { found = 0; $("li").each(function(){ if($(this).attr("class") == "selected") found = 1; }); if(found == 1) { var sel = $("li[class='selected']"); sel.next().addClass("selected"); sel.removeClass("selected"); } else $("li:first").addClass("selected"); } break; case 38: { found = 0; $("li").each(function(){ if($(this).attr("class") == "selected") found = 1; }); if(found == 1) { var sel = $("li[class='selected']"); sel.prev().addClass("selected"); sel.removeClass("selected"); } else $("li:last").addClass("selected"); } break; case 13: $("#ajax_response").fadeOut("slow"); $("#keyword").val($("li[class='selected'] a").text()); break; } } } else $("#ajax_response").fadeOut("slow"); }); $("#ajax_response").mouseover(function(){ $(this).find("li a:first-child").mouseover(function () { $(this).addClass("selected"); }); $(this).find("li a:first-child").mouseout(function () { $(this).removeClass("selected"); }); $(this).find("li a:first-child").click(function () { $("#keyword").val($(this).text()); $("#ajax_response").fadeOut("slow"); }); }); }); any help would be appreciated thanks Luke Is there a way to redirect your site to another site if the browser doesn't support HTML 5? So, if you where using an old version of IE or Firefox that didn't support HTML 5 it would redirect them to another page. Hi How to hide the real url and dispaly to specific url on a website. i.e. http://www.myapp.com/information.jsp is real url and want to dispaly http://www.myapp.com/ URL on browser. I will display as static URL instaead of real url. Please give an idea sugegstion how to do this bcoz I m new in JS. Thanks Lalit I found this script on a tutorial site but it had no summary of browser compatibility or any other issues. I know absolutely nothing about javascript and, although it works fine when I test it, I would appreciate it very much if someone else would review this page and give me feedback. Code: <head> <script type="text/javascript"> lastone='empty'; function showIt(lyr) { if (lastone!='empty') lastone.style.display='none'; lastone=document.getElementById(lyr); lastone.style.display='block'; } </script> </head> <body> <!--links--> <a href="JavaScript:;" onClick="showIt('divID1')" ">link1</a> <a href="JavaScript:;" onClick="showIt('divID2')" ">link2</a> <a href="JavaScript:;" onClick="showIt('divID3')" ">link3</a> <a href="JavaScript:;" onClick="showIt('divID4')" ">link4</a> <!--layers--> <div id="divID1" style="display:none;">content1</div> <div id="divID2" style="display:none;">.content2</div> <div id="divID3" style="display:none;">..content3</div> <div id="divID4" style="display:none;">...content4</div> </body> Here is a demo of it in action: http://www.mousegrey.com/layers.html Hi, I am using a script called osDate and I am trying to modify the sign up form to suit my setup. So far I have the below, but I would like to check a set ofradio buttons, but not sure, how to add it into the current code. var alphanumeric_chars = "0123456789.+-_#,/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ()_"; var alphanum_chars = "0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; var text_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz /'"; var full_chars = "0123456789.+-_#,/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz() _$+=;:?'"; <script type="text/javascript"> /* <![CDATA[ */ function validateme(form) { var tos_ok = form.accept_tos.checked; ErrorCount=0; ErrorMsg = new Array(); /* log details */ CheckFieldString("noblank",form.username,"Please enter the username."); CheckFieldString("alphanum",form.username,"Only letters, numbers and underscores '_' are allowed in the username."); CheckFieldString("noblank",form.email,"Email must be specified."); CheckFieldString("email",form.email,"Email address is not valid."); CheckFieldString("noblank",form.firstname,"First Name must be specified."); CheckFieldString("text",form.firstname,"Only letters are allowed in First Name."); CheckFieldString("noblank",form.lastname,"Last Name must be specified."); CheckFieldString("text",form.lastname,"Only letters are allowed in Last Name."); CheckFieldString("noblank",form.address1,"Last Name must be specified."); CheckFieldString("full",form.address1,"Only letters, numbers and underscores '_' are allowed in the password."); CheckFieldString("full",form.address2,"Only letters, numbers and underscores '_' are allowed in the password."); CheckFieldString("noblank",form.city,"Last Name must be specified."); CheckFieldString("text",form.city,"Only letters are allowed in Last Name."); if(form.username.value.length >= 5 && form.username.value.length <= 20){ if ( !isNaN(form.username.value.charAt(0)) ){ ErrorCount++; ErrorMsg[ErrorCount] = "Username must start with a letter." ; } }else{ ErrorCount++; ErrorMsg[ErrorCount] = "Number of characters in username should be between the specified range." ; } if (tos_ok != true) { ErrorCount++; ErrorMsg[ErrorCount]="Please read and accept the Terms of Service before registering"; } /* concat all error messages into one string */ result=""; if( ErrorCount > 0) { result = "---- Following errors occured -----"+ String.fromCharCode(13)+ String.fromCharCode(10); for( c in ErrorMsg) result += ErrorMsg[c]+ String.fromCharCode(13)+ String.fromCharCode(10)+ String.fromCharCode(10); alert(result); return false; } return true; } /* ]]> */ </script> Hi, I am trying to run multiple videos in the JW player by clicking on different links.Its working fine in chrome and firefox, But it doesn't play viseos in IE. Kindly suggest me ...Thanks in advance..Here is the code. <script type="text/javascript"> function start(){ return playVideo("mediaspace","mediawindow"); } function playVideo(sourceId, targetId) { if (typeof(sourceId)=='string') {sourceId=document.getElementById(sourceId);} if (typeof(targetId)=='string') {targetId=document.getElementById(targetId);} targetId.innerHTML=sourceId.innerHTML; return false;} </script> <body onload="start()"> <div id="mediawindow"></div> <div id="mediaspace" class="fltrt" style="display:none"> <script type='text/javascript' > var so = new SWFObject('player.swf','mpl','360','295','9'); so.addParam('allowfullscreen','true'); so.addParam('allowscriptaccess','always'); so.addParam('wmode','opaque'); so.addVariable('playlistfile','IIA2010.xml'); so.addVariable('stretching','fill'); so.addVariable('autostart','true'); so.addVariable('repeat','list'); so.addVariable('skin','stormtrooper.zip'); so.write('mediaspace');</script></div> <p><a href="#" onclick='return playVideo("mediaspace","mediawindow")'>Play all</a><br /> <a href="#" onclick='return playVideo("welcome","mediawindow")'>MC Linda Clark welcomes guests</a><br /></p> You can also have a look on the webpage. Its working well in FF and chrome. you can test it there. http://www.internetindustryawards.co.nz/2010.html Its really urgent... Hey Guys, I've been working on a WP site that uses a handful of plugins - several of which include java-script files. I've been having trouble with one of the plugins and have started the debugging process and noticed that the page the problem is occurring on shows a few java-script errors. http://proshotsrange.com/test-contact-page/ What do the "Object Not Supported" errors mean - and what would it entail to fix them? Thanks in advance. Code: Webpage Error Details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Timestamp: Mon, 22 Nov 2010 16:43:02 UTC Message: Object doesn't support this property or method Line: 143 Char: 2 Code: 0 URI: http://proshotsrange.com/wp-content/plugins/wp-e-commerce/js/wp-e-commerce.js?ver=3.7.58 Message: Object doesn't support this property or method Line: 4621 Char: 7 Code: 0 URI: http://proshotsrange.com/wp-includes/js/prototype.js?ver=1.6.1 Message: 'style' is null or not an object Line: 33 Char: 6 Code: 0 URI: http://proshotsrange.com/wp-content/plugins/lightbox-2/lightbox.js?ver=1.8 for (var i=0; i < document.myform.registrationtype.length; i++) { if (document.myform.registrationtype[i].checked) { var registrationtype = document.myform.registrationtype[i].value; } } what is wrong with this? i'm trying to get the value of registrationtype (a radio box) i'm getting an error object doesn't support this propery or method My website is working perfectly on Firefox but when I visit it with IE(7), I get the following errors and some things aren't where they're supposed to be. Quote: Webpage Script Errors User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30618) Timestamp: Fri, 25 Sep 2009 08:31:56 UTC Message: Object doesn't support this property or method Line: 8 Char: 186 Code: 0 URI: http://icarwakim.com/media/system/js/mootools.js Message: Object doesn't support this property or method Line: 59 Char: 102 Code: 0 URI: http://icarwakim.com/media/system/js/mootools.js Website: http://www.icarwakim.com Any advise? Dear All: My apologies - this is probably something that comes up time and time again. However, I was wondering - I realize there does not seem to be a "standard" way to do this (without additional libraries), but is there any "hacky" method that can be used to get XPath support in IE? What I mean is for parsing the loaded HTML document. Thank you Misha I have looked at the various posts about setting onclick in IE and I cannot see any that exactly describe the problem I am having. Firstly I am not trying to set onclick by calling setAttribute, which most of the posts describe. I am simply assigning a value to the onclick attribute of the element, which those posts seem to imply. Specifically I am getting "Object doesn't support this action" on the following line: Code: editButton.onclick = editCitation; editCitation is already a function, so I do not see why I should have to wrap it in an anonymous function wrapper to get IE to permit the assignment. I'm Sunita. I am working in ASP .net . I have created Class1.dll file . and in javascript I am creating ActiveXobject . when i debug the application . Its gives error like Object doesn't support this property or method. my code is Code: Class1.cs using System; using System.Collections.Generic; using System.Text; using System.IO.Ports; namespace Ana7140 { public class Class1 { //Declare Variables string data = ""; string log = ""; bool DoneDataReceived = false; bool tare = false; private SerialPort comport = new SerialPort(); public void send() { //Send comport comport.Write("?1"); if (data.Length > 1) { data = data.Replace('\r', ' '); char sign = data[1]; string DelimeterStr = "+-"; char[] delimiter = DelimeterStr.ToCharArray(); string[] splited = null; splited = data.Split(delimiter); data = Convert.ToString(sign) + Convert.ToString(Convert.ToDouble(splited[1])); } else { data = ""; } } public string GetValue() { //Send command to port if (comport.IsOpen) { if (tare == true) { comport.Write("?1"); log = log + "Sent ?1 command"; //if (data.Length > 1) //{ // data = data.Replace('\r', ' '); // char sign = data[1]; // string DelimeterStr = "+-"; // char[] delimiter = DelimeterStr.ToCharArray(); // string[] splited = null; // splited = data.Split(delimiter); // data = Convert.ToString(sign) + Convert.ToString(Convert.ToDouble(splited[1])); //} //else //{ // data = ""; //} while (true) { if (DoneDataReceived == true) { DoneDataReceived = false; break; } } tare = false; }//end of if(tare==true) else { data = "-2"; } } else { data = "-1"; } //This will return the data only return data; } //To fetch the data from Serial Port public void port_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { if (comport.IsOpen) { //Reading Data from Serial Port data = comport.ReadLine();//.ReadExisting(); log += data; // GetValue(); if (data.Length > 1) { data = data.Replace('\r', ' '); char sign = data[1]; string DelimeterStr = "+-"; char[] delimiter = DelimeterStr.ToCharArray(); string[] splited = null; splited = data.Split(delimiter); data = Convert.ToString(sign) + Convert.ToString(Convert.ToDouble(splited[1])); } else { data = ""; } DoneDataReceived = true; //Done with data processing } } catch (Exception ex) { //MessageBox.Show(ex.Message); } } public string getLog() { return log; } //This Function initialiases the serial port //public void Initialise() //{ // try // { // isInitialise = true; // correct = false; // init = true; // //sending command to serial port for initialization // //comport.Write("*\n"); // } // catch (Exception ex) // { } //} public void Tare() { try { //sending command to serial port for initialization comport.Write("T\n"); tare = true; } catch (Exception ex) { } } //This function opens the comport public void Start() { try { //if previously comport is open the firstly close this connection then open again comport if (comport.IsOpen) { comport.Close(); } else { //set Baudrate value as 300 comport.BaudRate = 300; //to read data in string set Data bits as 8 comport.DataBits = 8; //set stop bits as 1 comport.StopBits = (StopBits)1; //set parity bit as None comport.Parity = (Parity)Enum.Parse(typeof(Parity), "None"); //Set Port Name as COM1 //comport.PortName = "COM1"; //Set Read Time Out as 100 comport.ReadTimeout = 100; //Open comport comport.Open(); //Call event for serial data received comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived); //data = ""; // comport.Write("?1"); } } catch (Exception ex) { } } //close the connection and close the comport public void Stop() { try { //check whether comport is open or not //if comport is open then close the comport if (comport.IsOpen) { //comport.ReadExisting(); comport.Close(); } } catch (Exception ex) { } }//End of Stop //To check Connection is Opened or not public string getStart() { string check = ""; try { if (comport.IsOpen) { check = "0"; //If the connection is opened,then check=0 } else { check = "-1"; //If the connection is closed,then check=-1 } }//End of try catch (Exception ex) { } return check; }//End of getStart } } JavaScript program is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head><title> Untitled Page </title> <script language="javascript"> var wshell; wshell=new ActiveXObject("Ana7140.Class1"); function GetVal() { var val= wshell.GetValue(); alert(val); } function setip() { wshell.Start(); wshell.Initialise(); alert(val); } function Stop() { wshell.Stop(); //alert(val); // wshell.Stop(); //alert(val); } function Tares() { wshell.Tares(); //alert(val); // wshell.Stop(); //alert(val); } </script> </head> <body> <form name="form1" method="post" id="form2"> <div> <a href="#" onclick="javascript:setip()"> Connect </a> <a href="#" onclick="javascript:GetVal()"> Acquire Weight </a> <a href="#" onclick="javascript:Stop()"> Disconnect </a> <a href="#" onclick="javascript:Tares()"> Tares </a> </div> </form> </body> </html> plz help me Hello I am in need of help desperatley. I am trying to get a video to launch from my homepage. see test homepage here http://www.nuviewinc.com/index3.html the video should pop up and play. Like it does here- http://www.nuviewinc.com/testv.html But it doesnt... can anyone help this poor marketing manager with coding? I simply followed the directions here http://www.vmatrixonline.com/vplayer...structions.pdf. all the code appears correct. Hi All, Need some urgent. We are having a javascript which is throwing the foll error "Object doesn't support this property or method". The javascript function being called is using a Scanner API. So this is using some ActiveX. Below is the code for javascript <script language="javascript"> // Initialize scanning function OnLoad() { try { Scanner.OpenScanner(); // Scanner.ScanPriority = 0; // Set scanner to Foreground Read mode before enable scanning // Scanner.EnableScanning(1); document.forms["mobileform"]["rm07m-bwartwe[1]"].value = "101"; } catch (e) { alert(e.message); } } // Clean up function OnUnload() { Scanner.CloseScanner(); // Calling Dispose is necessary for Pocket IE because of a Microsoft issue related to releasing object. if (navigator.appName == "Microsoft Pocket Internet Explorer") Scanner.Dispose(); } // Scan through soft trigger function Scan() { try { Scanner.SetSoftTrigger(1); } catch (e) { alert(e.message); } } //User-defined function to format error codes. //VBScript has a Hex() function but JScript does not. function hex(nmb) { if (nmb > 0) return nmb.toString(16); else return (nmb + 0x100000000).toString(16); } </script> There is a object tag in html <object id="Scanner"></object> The javascript functions are called from body tag. Can someone please provide some help. Thanks, Nikhil Hi, When I try and geocode an addres to my google map I receive the error: Object does not support this method or property I have gone over the script and can't work out what I did wrong. Code: <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #bookmark_map {width:90%; height:250px; margin-left:15px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> var geocoder; var map; function createGMapFromAddress(){ geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(0,0); var map_options = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("bookmark_map"), map_options); } function loadBookMarkMap(location){ alert(location); var address = location; alert(address); geocoder.geocode({address: address}, function(results, status){ if (status == google.maps.GeocoderStatus.OK && results.length){ if (status != google.maps.GeocoderStatus.ZERO_RESULTS){ map.set_center(results[0].geometry.location); var marker = new google.maps.Marker({ position: results[0].geometry.location, map: map }); } } else { alert("Geocode was unsuccessful due to: " + status); } }); alert(marker); } </script> </head> <body onload="createGMapFromAddress()"> //php get from table $possumshaw ="{$row['address']}"; } echo '<input type="button" class="button4" value="View Map" onclick="loadBookMarkMap(\'' . $possumshaw . '\')" />'; ?> I found strange for the following code: Code: var allextRules = Ext.util.CSS.getRules(); Object.keys(allextRules).forEach(function(key) { var keyname = key; if(keyname.indexOf("js") != -1){ Ext.util.CSS.removeStyleSheet(keyname); console.log(keyname + " Removed"); } }); When the above work is tested in other browser (say - Google Chrome), there is no error. However, when tested in IE 9, there is error as follows: Code: SCRIPT438: Object doesn't support property or method 'keys' According to this article (https://developer.mozilla.org/en/Jav...ts/Object/keys), the Object.keys is supported by IE. Have I miss out something? what's the fastest or easiest way to get all comment nodes into an Array? the solution only needs to work in ie8/w3 if that helps. Greetings, I am currently using the websites tutorial about browser detection using the navigator. http://www.javascriptkit.com/javatutors/navigator.shtml I am however finding myself unable to detect a pattern in order to learn from. My aim is to use Browser detection to have a CSS file for each browser type, such as Firefox, IE, Opera, Safari and then an overall CSS file if none of the above, to fix numerous flaws. For IE and Firefox using the site's code is all well and good and while I haven't tested it yet I'm wondering how to set up the coding so that it can detect a safari browser. There are lots of slashes and d's and brackets and I do find myself unable to understand their purpose. So if someone can explain how I could do it for Safari I would be very appreciative. I need a script that will redirect to a specific page is the browser is safari version 4. if the browser is NOT safari 4 I want the browser to stay on the current page.
|