JavaScript - A Script To Check If Javascript Enabled With A Disabling Div
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 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. 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 I've got this script working for grabbing and scrolling a website, and it's perfect; the only problem is I'd like to disable it when clicking a form (basically, not being able to drag scroll when clicking inside a form or input tag). This could be either by specifying a class or ID, whatever works best. This is the script, in case the website goes down or something: Code: <script type="text/javascript"> document.onmousedown = function(){ var e=arguments[0]||event; var x=zxcWWHS()[2]+e.clientX; var y=zxcWWHS()[3]+e.clientY; document.onmousemove=function(){ var e=arguments[0]||event; window.scroll(x-e.clientX, y-e.clientY); return false; } document.onmouseup=function(){ document.onmousemove=null; } return false; } function zxcWWHS(){ if (window.innerHeight) return [window.innerWidth-10,window.innerHeight-10,window.pageXOffset,window.pageYOffset]; else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth-10,document.documentElement.clientHeight-10,document.documentElement.scrollLeft,document.documentElement.scrollTop]; else if (document.getElementById("mailForm").onmousedown=null); return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop]; } </script> Also, would there be a way to enable grab scrolling just on the background? I mean, disabling it on images, text and any other element, and just leaving the empty spaces of the website with the ability to scroll. Thanks a lot in advance. 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> Ok I just gota ask... I read this originally and nearly killed my self laughing... then my brain got the best of me and my curiosity took over... is it possible to write a javascript code that makes your web browser disable javascript? is it even possible for Javascript to access a web browser in that sort of fashion? Like can a script have that much control? ... or rather lack of control and self suicidal... but anyways Is it possible? 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! plz check bold part of function is not working. what is wrong with it.? Code: function onesizecheck(chk_id,siz) { alert(chk_id); if(document.getElementById('siz_check').value=='') { document.getElementById('siz_check').value=siz; }//end if if(document.getElementById('siz_check').value==siz) { document.getElementById('siz_check').value=siz; } else { alert('Multi size are not allowed.'); for(var i = 0; i < document.delet['checkbox[]'].length; i++){ var cb = document.getElementById('checkbox'); alert(cb[i].value); } } }//end function Hi all I have this rollover script (original done by Old Pedant) which I have modified making it 5 sets of 2 images. Althogh it seems to work I have a feeling it's not the best way of doing it hahahaha It seems clumsy to me (and i'm no coder hahaaha) Could it be made more concise. (or just made correct) Would really appreciate any help or positive comments. Code: <script type="text/javascript"> function linkOver(link) { var image = link.getElementsByTagName("IMG")[0]; image.src = image.src.replace("Off_1.png","On_1.png"); image.src = image.src.replace("Off_2.png","On_2.png"); image.src = image.src.replace("Off_3.png","On_3.png"); image.src = image.src.replace("Off_4.png","On_4.png"); image.src = image.src.replace("Off_5.png","On_5.png"); } function linkOut(link) { var image = link.getElementsByTagName("IMG")[0]; image.src = image.src.replace("On_1.png","Off_1.png"); image.src = image.src.replace("On_2.png","Off_2.png"); image.src = image.src.replace("On_3.png","Off_3.png"); image.src = image.src.replace("On_4.png","Off_4.png"); image.src = image.src.replace("On_5.png","Off_5.png"); } </script> </head> I have 5 of these: Code: <body> <div id="megaanchor" onmouseover="linkOver(this), callSecondFunction('soldier',50,40,200);" onmouseout="linkOut(this);" ><img src="images/image_Off.png" alt="" border="0" /> </body> Hello all, Sorry for not reading the "posting guidelines" earlier. I understand that you guys are not reading/loading complete codes, my bad. Let me try again. This is a code for checking numbers A1 -> B1, when there is a match, the code will be green, otherwise black. Can somebody explain to me how I can extend this script, that more then one array is checked?? Code: <script type = "text/javascript"> var a1 = ["2","5", "11","16","23","45", "46"]; var b1 = ["2","3","8","12","23", "37", "41", "45", "48"] for (var i = 0; i< a1.length; i++) { for (var j = 0; j< b1.length; j++) { if (a1[i] == b1[j]) { a1[i]= "g"+ a1[i]; } } } for (var i = 0; i< a1.length; i++) { if (a1[i].substr(0,1) == "g") { a1[i] = a1[i].substr(1,20); document.write("<font color = 'green'>", a1[i] + "    "); } else { document.write("<font color = 'black'>", a1[i] + "    "); } } document.write("<br><br>"); for (var j = 0; j< b1.length; j++) { document.write("<font color = 'black'>", b1[j] + "    "); } </script> Thanks a ton in advance 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. 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, 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 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 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 NO knowledge of Javascript at all but borrowed and attempted to adapt one I found. It is a Firefox bookmarklet designed to highlight in different colours both certain words or the ending "ing" on a word in a text document that has been saved as html. Basically it is a device for helping novel writers rid their manuscripts of redundant words and overuse of the 'ing" words. In works in part but doesn't pick up all "ing" endings. For someone who know what their doing I imagine it would take more than a few minutes to read and correct. Many thanks to anyone who can help. Here is the Javscript: javascript:var%20verbsRE=/(\b)(about|actually|almost|already|appear|approximately|basically|close to|even|eventually|exactly|finally|here|just|kind of|nearly|now|practically|really|seem|simply|somehow|somewhat|sort of|suddenly|then|there|truly|utterly|while|as|appear|felt|gaped|gawked|gazed|glanced|hear|heard|knew |looked|noticed|observed|peered|peeped|regarded|saw|scanned|see|seeing|seemed|smelled|stared|studied |surveyed|tasted|viewed|watched)(\b)/gi;var%20ingRE=/(\w)(ing)(\b)/gim;function%20HL(node){if(node.hasChildNodes){var%20hi_cn;for(hi_cn=0;hi_cn<node.childNodes.length; hi_cn++){HL(node.childNodes[hi_cn]);}}if(node.nodeType==3){var%20tempNodeVal=node.nodeValue;if(verbsRE.test(tempNodeVal)){tempNodeVal= tempNodeVal.replace(verbsRE,"$1<span%20style='background-color:yellow;color:black;border:1px%20solid%20black;'>$2</span>$3");tempNodeVal=tempNodeVal.replace(ingRE,"$1<span%20style='background-color:#0ff;color:black;border:1px%20solid%20black;'>$2</span>$3");newNode=document.createElement('span');newNode.innerHTML=tempNodeVal;pn=node.parentNode;pn .replaceChild(newNode,node);}}}HL(window.document.getElementsByTagName('body')[0]); Hello, I have never used javascript before, so this might be a very basic question. I have a script on my blog which places a stumbleupon button on the page. This is the code that calls the script: Code: <script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script> Today I went to my blog and it was taking a long time to load, it turns out because stumbleupons site is down so the script can't be accessed. A whole lot of other stuff on the page just doesn't load until it times out though, so it takes like 3 minutes for the page to load. What I want to know is can I test if the script is reachable and only call it if it is, so that if there is a 403 or 404 error it just won't even try to load it and continue loading the rest of the page?? Any help is greatly apprectiated! Thanks. I got a page that gets created dynamically. sometimes I get images output with NO source like this Code: <img src="" id="md_1"> <img src="" id="md_2"> etc. etc. the image id are created dynamically also and always start with "0" and count up in order. I need to check everyone of those image links and when they are blank like above change the src to a default image. I have spent 8 hours on this one simple function and cannot seem to get it to work. I will call the function at the end of the page. string check in javascript do suggest me something ....... if you have any two words like , "me" and "you". Okay this is part of an ajax driven shopping cart. the problem is i need to check for 2 different selections that would be for the same payment method. here is the code as it sits now Code: if ( typeof document.checkout.payment[3] != 'undefined'){ if (document.checkout.payment[3].checked == true) { if (document.checkout.cc_owner.value == "" ) {errMsg += 'Please complete or verify the information in the Name on the card field in the \'Payment Method\' section.' + "\n"; } else { if(document.checkout.cc_number.value == "") { errMsg += 'Please complete or verify the information in the Card Number field in the \'Payment Method\' section.' + "\n"; } else { if(document.checkout.cc_cvv2.value == "") { errMsg += 'Please complete or verify the information in the CVC/CVV code field in the \'Payment Method\' section.' + "\n"; } else { if(document.checkout.cc_phone.value == "") { errMsg += 'Please complete or verify the information in the Card company\'s telephone number field in the \'Payment Method\' section.' + "\n"; } else { myCardNo = document.checkout.cc_number.value; myCardType = document.checkout.surcharge.value; if (!checkCreditCard (myCardNo,myCardType)) { errMsg += 'Please complete or verify the information in the Card Number field in the \'Payment Method\' section.' + "\n"; } } } } } }} } the problem is in the first 2 lines i basically need it to do this, but when i do it like how i need it to be it will not work. it looks like i am doing it incorrectly maybe. firebug gives me an undefined error on the first checked value because it does not exist when i need it to check for the 2 value. Code: if ( typeof document.checkout.payment[3] != 'undefined' || typeof document.checkout.payment[2] != 'undefined'){ if (document.checkout.payment[3].checked == true || document.checkout.payment[2].checked == true) { if (document.checkout.cc_owner.value == "" ) {errMsg += 'Please complete or verify the information in the Name on the card field in the \'Payment Method\' section.' + "\n"; } else { if(document.checkout.cc_number.value == "") { errMsg += 'Please complete or verify the information in the Card Number field in the \'Payment Method\' section.' + "\n"; } else { if(document.checkout.cc_cvv2.value == "") { errMsg += 'Please complete or verify the information in the CVC/CVV code field in the \'Payment Method\' section.' + "\n"; } else { if(document.checkout.cc_phone.value == "") { errMsg += 'Please complete or verify the information in the Card company\'s telephone number field in the \'Payment Method\' section.' + "\n"; } else { myCardNo = document.checkout.cc_number.value; myCardType = document.checkout.surcharge.value; if (!checkCreditCard (myCardNo,myCardType)) { errMsg += 'Please complete or verify the information in the Card Number field in the \'Payment Method\' section.' + "\n"; } } } } } }} } |