JavaScript - Only Display If Js Is Enabled
The navigation for the web site I'm doing requires JS to remotely work so I want to make some kind of back-up scenario. Basicly, how can I make it so my main navigation will only display if there is script?
One thought I had was put it in a div, hide it in the CSS, then use JS to show it but if there is a better way to do this I'd like to know. Similar TutorialsHey guys, i'm trying to set up a favorite system for my website and I'm using ajax to do an async request to the server to run a php script. The problem is that i'm running joomla with sef enabled. So whenever i'm on a page the URL looks like: mysite.com/Category-Name/Item-Name/ when i click on the favorite button it will look like this mysite.com/Category-Name/Item-Name/favorite.php?all-the-stuff-that-is-being-sent-to-the-file This obviously doesn't work... I followed this tutorial: http://woork.blogspot.com/2007/10/in...sing-ajax.html My question is how do i fix this.. can i get the base URL or something? I am a TOTAL noob to javascript. i somewhat understand it, but i have no clue what i'm doing. I just have basic programing knowledge through MATLAB and PHP... BTW, the key here is not to leave the site Thanks for the help in advance EDIT added my domain name in front of the location of the file and fixed the problem =) Hi all, The code I am working on uses the idea of detecting mime type support, to see if the add-on is there. Then if the mime type is not supported, it assumes, the add-on is not installed. (No other add-ons have this mime type.) However, there is a problem, if someone disables the add-on, the there is no mime type handler in navigator.mimeTypes['the/MimeType']. Is there some way to detect if an add-on is installed, and also if the add-on is enabled? Thanks, Grae Hi, I'm just wondering if I can do a check on my page to determine if users have javascript enabled, and if not, redirect them to a different webpage. My site requires javascript, and without it, all the jquery popup boxes and stuff overlap, so I'd rather the user just not see any of that at all. Hi all. This is a generic question as Google didn't help at all, does anyone know how to check if javascript is enabled and then I want to display info based on that. I don't mind how I do it, HTML, PHP or whatever Regards, Magnetica Hi, I'm wanting to make a submenu appear on the page when a menu item is mouse-overed. I can find examples online where UL and LI are used, but that won't work in my layout: http://www.girlscoutsmoheartland.org/newpagetest.php Here, the menu items like "home" and "for girls" need to generate a horizontal submenu below where "menu item A" and "menu item B" are, and each submenu would appear in the same location as the other submenus, disappearing and appearing as a different menu item above is hovered over. All I can find are like this: http://htmldog.com/articles/suckerfish/dropdowns/ and I can't figure a way to conform that to this layout. Can someone point me to a site that has a solution for this situation? Thanks! Liam Hi all, I am writing an administration panel for a web site. I want to check if the client's browser javascript enabled and if it is not enabled, a warning DIV comes telling the client to enable javascript and disable the actual page (make the actual page non-usable). Is there a way to do that? Thanks in advance telmessos We all know AC_OETags.js. URL like: http://www.adobe.com/products/flashp...detection_kit/ How to make flash detection in variable with valu true or false if it is (not) detected to use in PHP applications? I have an auto submit form example.. Code: <form name = "backtosource" method="POST" and the rest of this is fine> blah blah </form> <script type="text/javascript"> function process_data_return() { document.backtosource.submit(); } </script> <script type="text/javascript"> <!-- process_data_return(); // --> </script> so this works for everyone of my people other than one who is on a debian server, we all use centos. i know this is cleint side but i wanted to mention that. this user has the js enabled on all his browsers. so what would cause his browser not to execute the js auto submit, we know this to be the issue but cannot resolve. thanks i guess i could try the old cdata wrap trick Code: // <![CDATA[ js code // ]]> but i dont want it to affect those that this is working. What is a good switch value to use so i can build an if statement. Is there a current local value i can trap for comparison Hello, I would like to know how to make a website (in this case, a parent div) viewable only if JavaScript is enabled? I tried to develop a code that can do this, but could not find the solution. Code: <html> <head> <script type="text/javascript"> window.onload=function() var="true" if(JavaScript.enabled) { document.getElementById('true') } OnClick() {document.getElementById('toggle').onclick=function() {document.getElementById('jahava').style.display=(document.getElementById('jahava').style.display!='none')?'none':'';}} </script> </head> <body> <noscript>You must have JavaScript enabled to view the website.</noscript> <div id="jahava">Contents Here</div> </body> </html> Hi, a friend of mine has a problem on several (German) Legend of the Green Dragon (lotgd) servers. Sometimes, mostly after she has loged in and out for a few times during a day, she suddenly gets the message that Javascript must be enabled to log in. But it definetely IS enabled - otherwise she'd never be loged in! The error occurs - on 2 different PCs - with 2 different internet providers - with IE, FF and Opera - only on lotgd servers - any other page using Javescript are working fine We - updated and downgraded Javascript - disabled and/or uninstalled all antivirus and firewall programms - cleaned cache with CCleaner - disabled browser add ons - reinstalled Windows - disabled auto-insert passwords Even a reboot doesn't change anything. Sometimes, when she waits a few hours, she can log in again. Sometimes the error doesn't occur for days, sometimes it's there every day. That's why it is so strange. Although she doesn't change anything, the error comes and goes completely irregular. The games' admins can't or don't want to help, they say that she's the only one with that problem and that it's not a mistake in the script. What might occur that error? And what can we do to stop it?? That's what the Opera error console says: JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' CSS - http://lotgd.demonstone.org/templates/yarbrough.css Linked-in stylesheet xbackground-color is an unknown property Line 1: eight:auto;padding:1px;line-height:18px;float:left;clear:none;xbackground-color: --------------------------------------------------------------------------------^ JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' JavaScript - http://lotgd.demonstone.org/index.php Uncaught exception: ReferenceError: Undefined variable: calcMD5 Error thrown at line 1, column 0 in <anonymous function>(event): document.forms.loginform .hidden_pw.value = calcMD5(document.forms.loginform .password.value); JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' JavaScript - http://lotgd.demonstone.org/index.php Uncaught exception: ReferenceError: Undefined variable: calcMD5 Error thrown at line 1, column 0 in <anonymous function>(event): document.forms.loginform .hidden_pw.value = calcMD5(document.forms.loginform .password.value); JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' JavaScript - http://lotgd.demonstone.org/index.php Uncaught exception: ReferenceError: Undefined variable: calcMD5 Error thrown at line 1, column 0 in <anonymous function>(event): document.forms.loginform .hidden_pw.value = calcMD5(document.forms.loginform .password.value); JavaScript - http://lotgd.demonstone.org/index.php Inline script compilation Syntax error at line 21 while loading: b|(~d)),a,b,x,s,t);}*/ --------------------^ expected expression, got '*' I hope someone is able to help. Thank you! Why isnt this working? Code: function display_form(obj) { var button_name = obj.id.split("dialog_"); var t = document.getElementById(button_name[1] + '_form').style.visibility = 'visible'; alert(t); } IE is saying: Code: id is 'null' or not an object I'm trying to set an if statement so if one element is set to display:none, another element(s) sets margin-left to a certain number of pixels. Sort of like this (however, it's not working): Code: <script> if (document.getElementById('#why-choose-content').style.display = 'none') { document.getElementById('#always-content').style.margin-left = '335px'; } </script> Here is the site in question: http://bit.ly/8XfM0Q You can get a better idea of what I mean by clicking the 'plus' icons for the three colored tabs above the main content. Or if anybody has a more elegant way to get the divs to toggle under their respective headers, I'd love to hear. Thank you. [Hi all! I am obviously new to Javascript, blah blah blah, etc ... Please help me by pointing out what is wrong with my code while changing as little as possible ... and if you could also please explain the part that says t = total( parseFloat(a,10), parseFloat(b,10), parseFloat(c,10), parseFloat(d,10)); if(!isNaN(t)) f.value = t; as I copied that portion from someone and I really don't understand it. Thank you soooo much!] <html> <head> <title>Problem 3</title> <style type="text/css"> body { background-color:blue; font-family:verdana; font-size:large; } input { width: 60px; } </style> <script type="text/javascript"> var f = (a*0.1)+(b*0.15)+(c*0.25)+(d*0.2)+(e*0.3) if ( grade5Obj.value.length < 1 ) alert("Please enter a grade in every box!"); else displayObj.value=ourText + nameObj.value + '!'; }; function update() var a = document.getElementById( 'grade1' ).value, b = document.getElementById( 'grade2' ).value, c = document.getElementById( 'grade3' ).value, d = document.getElementById( 'grade4' ).value, e = document.getElementById( 'grade5' ).value, f = document.getElementById( 'ans' ), t=0; t = total( parseFloat(a,10), parseFloat(b,10), parseFloat(c,10), parseFloat(d,10)); if(!isNaN(t)) f.value = t; </script> </head> <body> <form action="" method="post"> <p>Enter the first grade <input id="grade1" onkeyup="update()"><br> <p>Enter the second grade <input id="grade2" onkeyup="update()"><br> <p>Enter the third grade <input id="grade3" onkeyup="update()"><br> <p>Enter the fourth grade <input id="grade4" onkeyup="update()"><br> <p>Enter the fifth grade <input id="grade5" onkeyup="update()"><br> <p>Your final grade is <input name="finalGrade" readonly="true"> <input type="button" value="Click me!" onclick="finalGrade value=document.getElementById( 'ans' )"></p> </form> </body> </html> Hi There, I am attempting to do a site which is of a similar format to a TV listings website. Each day's schedule will be on a different HTM page (contained within an iFrame), and I would like it to display the current day's schedule on the appropriate day. I have searched the forum, but can't find anything exactly like this (maybe I'm searching for the wrong thing), so any answers greatly appreciated. Thanks, Roz Hi, I am trying to have an array of pictures rotating among them every 300 milliseconds. I am having a hard time to walk through the arrays to set new x and y values and rotate them to the new place. I think I have problems with my display code, where I should display the new position every time I call settimeout, exchanging the positions x and y from the array indexes position. There is my code: Code: <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>hexagonal array</title> <script type="text/javascript"> <!-- var pixArray = Array(6); function shiftPix(element, count, index) { var pi = 3.1415926535; // left: x coordinate, top: y coordinate y = 300 + 150 * Math.cos(2 * pi * (count + index)/6); x = 300 + 150 * Math.sin(2 * pi * (count + index)/6); element.style.left = x + "px"; element.style.top = y + "px"; } function display() { for (j = 0; j < 6 ; j++) { setTimeout("shiftPix(" + x + ", " + y + ")", 300); counter++; shiftPix(pixArray[j], counter, j); } } // --> </script> </head> <body> <h3>Hexagonal Array </h3> <div id="John" style="position:absolute;left:300px;top:450px"> <img src="picture1.jpg" alt="John Santore" width="90" height="120" /> </div> <div id="Seikyung" style="position:absolute;left:430px;top:375px"> <img src="picture2.jpg" alt="Seikyung Jung" width="90" height="120" /> </div> <div id="Glenn" style="position:absolute;left:430px;top:225px"> <img src="picture3.jpg" alt="Glenn Pevlicek" width="90" height="120" /> </div> <div id="Lee" style="position:absolute;left:300px;top:150px"> <img src="picture4.jpg" alt="Lee Mondshein" width="90" height="120" /> </div> <div id="Abdul" style="position:absolute;left:170px;top:225px"> <img src="picture5.jpg" alt="Abdul Sattar" width="90" height="120" /> </div> <div id="Toby" style="position:absolute;left:170px;top:375px"> <img src="picture6.jpg" alt="Toby Lorenzen" width="90" height="120" /> </div> <script type="text/javascript"> <!-- var counter = 0; pixArray[0] = document.getElementById("John"); pixArray[1] = document.getElementById("Seikyung"); pixArray[2] = document.getElementById("Glenn"); pixArray[3] = document.getElementById("Lee"); pixArray[4] = document.getElementById("Abdul"); pixArray[5] = document.getElementById("Toby"); display(); // --> </script> </body> </html> helow to all im new here? iwant to ask on how to display the sum of the 20 numbers i allready get the everage but i want to display the sum together of the everage this my code.. <html> <body> <script type = "text/javascript"> var numtotal = parseInt(prompt("How many numbers do you want to sum up?","")); var total = 0; for (var i=0; i<numtotal; i++) { var ans = parseFloat(prompt ("Enter a number", "")); if ((isNaN(ans)) || (ans == "")) { alert ("You must enter a number!! "); i -- ; } else {total = total + ans/numtotal}; } alert (total); // the total </script> </body> </html> any body help me please? Hi, I thought this would be relatively simple, but it's more complicated than I thought, and I can't seem to find the question resolved anywhere. My problem is that on my site I sometimes have promotions that will end at midnight. I have to physically change the code at midnight to remove the promotional material. How would one go about using Javascript to only display a <div> during a certain time? Like "Use coupon code 123 to get free shipping! Good until midnight!" and set it to stop displaying that content at 12:00 AM. Then I could remove it the next day. Or the opposite, and have it take effect a midnight, etc. I'm sure it's been done before, right? Hello everyone. I'm using the script Old Pedant posted here (huge thanks man!), however, I'm looking to have the timer display six numbers at all times. For example: If the timer has 15 hours, 35 minutes, and 10 seconds left it is currently displaying as: 15:35:10 - Perfect! If the timer has 5 hours, 35 minutes, and 10 seconds left it is currently displaying as: 5:35:10 - Humm, not so perfect. In the second example, would like the timer to keep a zero in front of the hours when ever it drops below 10. So the second example should display as: 05:35:10. Any help is greatly appreciated. Posted below is the modified code I'm using. Thanks! Code: <html> <head> <script type="text/javascript"> // really really simple to get the time from the server // this is for an ASP server: //var serverTime = <%= DateDiff("s",#1/1/1970#,Now())%>; // PHP Servers: var serverTime = <?php echo time(); ?>; // serverTime will hold the number of seconds since 1/1/1970 0:00:00 as it is on the server // we must adjust it to compensate for GMT offset // My server is on Pacific Daylight Time, so 7 hours offset: serverTime += 0 * 3600; // 7 hours, 3600 seconds per hour // NOTE: This adjustment MAY NOT be needed for PHP servers...I dunno. // // so calculate how far off the client is from the server: var now = new Date(); var clientTime = now.getTime(); // number of *milliseconds* since 1/1/1970 0:00:00 on client serverTime *= 1000; // convert server time to milliseconds, as well // the client and server disagree by this much: var clockOff = serverTime - clientTime; // could well be negative! // hopefully you can see, from basic algebra, that // serverTime = clientTime + clockOff // we want target to be 0:00:00 of next day var target = new Date( serverTime ); // serverTime in JS form // so bump the day by one and leave time as 0,0,0: target = new Date( target.getFullYear(), target.getMonth(), target.getDate() + 1 ); // and now ready for our timer countdown: var ticker = null; // the interval timer function countdown( ) { var clientNow = ( new Date() ).getTime(); var serverNow = clientNow + clockOff; // see? this is where we use that offset! var millisLeft = target.getTime() - serverNow; // milliseconds until server target time var secsLeft = Math.round( millisLeft / 1000 ); var timeLeft; var timeLeftWords; if ( secsLeft <= 0 ) { timeLeftWords = "Expired!"; timeLeft = "0 days 00:00:00"; clearInterval( ticker ); } else { var secs = secsLeft % 60; var minsLeft = Math.floor( secsLeft / 60 ); var mins = minsLeft % 60; var hrsLeft = Math.floor( minsLeft / 60 ); var hrs = hrsLeft % 24; var days = Math.floor( hrsLeft / 24 ); timeLeftWords = days + " days, " + hrs + " hours, " + mins + " minutes, " + secs + " seconds"; timeLeft = + (hrs < 10 ? "0" : "" ) + hrs + ":" + (mins < 10 ? "0" : "" ) + mins + ":" + (secs < 10 ? "0" : "" ) + secs; } document.getElementById("ticktock").innerHTML = timeLeft; } function startup( ) { countdown(); // first time setInterval( countdown, 1000 ); // then once a second } </script> </head> <body onload="startup()"> Time: <span id="ticktock"></span><br/> </body> </html> Hello everyone, I need help to show popup only once a day per user! The Problem is that the users of my blog gets mad when the popup displays, so i only want to show it once a day. please add the codes to it fully and send it back over thanks! [CODE]<link href='http://pwnagesource.netii.net/java/jquery.fancybox.css' media='screen' rel='stylesheet' type='text/css'/> <!--[if lte IE 6]><link href="java/jquery.fancybox_ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]--> <script src='http://pwnagesource.netii.net/java/jquery-1.4.3.min.js' type='text/javascript'/> <script src='http://pwnagesource.netii.net/java/jquery.fancybox-1.3.4.js' type='text/javascript'/> <script type="text/javascript"> $j = jQuery.noConflict(); $j.fn.countDown = function(settings,to) { settings = jQuery.extend({ startFontSize: '14px', endFontSize: '14px', duration: 1000, startNumber: 10, endNumber: 0, callBack: function() { } }, settings); return this.each(function() { //where do we start? if(!to && to != settings.endNumber) { to = settings.startNumber; } //set the countdown to the starting number $j(this).text(to).css('fontSize',settings.startFontSize); //loopage $j(this).animate({ 'fontSize': settings.endFontSize },settings.duration,'',function() { if(to > settings.endNumber + 1) { $j(this).css('fontSize',settings.startFontSize).text(to - 1).countDown(settings,to - 1); } else { settings.callBack(this); } }); }); }; </script> <script type="text/javascript"> $j(function() { $j.fancybox( "<div style='margin-left: 20px;'></br><h3 style='background-color: #000; padding: 8px; color: white; text-shadow: white 1px 2px 2px;-moz-text-shadow: black 1px 2px 2px;-webkit-text-shadow: black 1px 2px 2px;font-weight: bold;font-family: \"Trebuchet MS\", Helvetica, Geneva, san-serif; font-size: 20px; '>TheEmoLab" | Subscribe To Our Newsletter!</h3><center></br><td align='left'> <p style='color:#666; font-style:italic; margin:0px 0px 5px 0px; '>Get Free Email Updates Daily!</p></td><form action='http://feedburner.google.com/fb/a/mailverify' class='emailform' method='post' onsubmit='window.open('http://feedburner.google.com/fb/a/mailverify?uri=theemolab/feed', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true' style='margin: 0pt;' target='popupwindow'><input name='uri' type='hidden' value='theemolab/feed'/><input name='loc' type='hidden' value='en_US'/><input class='mbttext' name='email' onblur='if (this.value == "") {this.value = "Enter your email...";}' onfocus='if (this.value == "Enter your email...") {this.value = ""}' type='text' value='Enter your email...'/><input alt='' class='mbtbutton' title='' type='submit' value='Submit'/></form></tr></tbody></table></center></br><hr style='padding-bottom: 0; margin: 0 0 7px 0;' /><p style='padding-bottom:0;text-align: center; font-weight: bold;margin-top: 0; padding-top:0;'>This dialog box will close in <span id='dialog_close_countdown'>30</span> seconds.</p></div>", { 'autoDimensions' : false, 'width' : 500, 'height' : 215, 'overlayOpacity' : '0.8', 'overlayColor' : '#000', 'onComplete' : function() { $j('#dialog_close_countdown').countDown({ startNumber: 30, callBack: function(me) { $j.fancybox.close(); } }); } }); }); </script>[ICODE] hey all, Am trying to display the div tag and its content by clicking it. the code below displays the whole source code when cliked on the div with id = softros. I want to make this script to display the div in view source format of the browser when clicked on any div. Thanks in advance, looking forward for your ideas Regards, Bala <html> <head> <script> function viewSource() { window.open('view-source:'+location.href); } </script> </head> <body> <div id="softros" onClick="viewSource();" style="border:1px red solid;"> <img src="images/rain_small.jpg" alt="rain_small" title="rain_small" /> </div> </body> </html> |