JavaScript - Noscript To Redirect
Hello everybody,
What I have been trying to incorporate into my site is that if a user has javascript turned off, it redirects them to another page. This is what I have found but doesn't seem to work. Code: <NOSCRIPT> <meta http-equiv=”refresh” content=”0; URL=AlternatePage.cfm”> </NOSCRIPT> When I test it out it shows on the page like this: meta http-equiv=”refresh” content=”0; URL=AlternatePage.cfm” Basically shows the same thing without the tags. It doesn't take any action at all. Any ideas, tips, or advice? I don't have any access to the root directory so SSI is not an option at the moment. (Do plan of hosting it on a dedicated server when I have the money ) Similar TutorialsSo I was going to comment on another thread that was up a few days ago, but it is resolved and figured best to not repost on it anyways (can you repost on a resolved thread?) anyways... it was this thread and as rnd_me said the <noscript> tag is only supposed to be used in the body. So the reason I began thinking of this is because I am coding asp.net and using a master page. I cannot have <head> tags in the child pages because they get their <head> tags from the master... so i ran into the issue of redirecting clients if they do/do not have js enabled. the problem is if i use a script in the <head> on the master page and then the children get it, everytime a user clicks a link to goto a page they will be redirected to the default js page (script that redirects will be placed on every page). So I am playing around with how to do this the easiest and thought of that thread and thought, well if my default page is the "js enabled page" then i can put the noscript tag in the body and it will redirect users to the non js page and then i no longer have to worry about using the script in the <head> tags... am I making sense? upon further thought though you can put <script> tags anywhere, it is just generally placed in the <head> <-- this is an accurate statement correct?.... so i guess my question/reason for this post is to get feedback... i think it might be a "6, half-dozen the other" situation and just pend on "my style" but do you guys feel (keep in mind that this has to be done outside the <head> tag and inside the <body> tag) it is better to have default page be for script disabled and have a <script> which redirects, or the default page be js enabled and use the <noscript> tag? I guess it would come down to which one processes quicker? any thoughts on this would be great- I feel i have an answer (well two) but wanted feedback on which is better (and preferably a reason as to why one is better eg speed or something)... also if anyone reading could correct me if I am thinking incorrectly about this whole matter that would be great too I have a simple form and the noscript tag I have inserted is displaying as not valid as it is within the form section. Where could I place the noscript tags. Code: <form id="form" action="process.php" enctype="multipart/form-data" method="post" name="form_to_email" onsubmit="return Validate();"> <fieldset> <legend>Your details</legend> <p><label for="name"><span>* Name:</span></label><input id="name" name="name" size="45" type="text"/></p><p><label for="email"><span>* Email:</span></label><input id="email" name="email" size="45" type="text" /></p><p><label for="subject"><span>* Subject:</span></label><input id="subject" name="subject" size="45" type="text" /></p></fieldset><fieldset class="message"> <legend>Message</legend><textarea id="message" name="message" cols="55" rows="5"></textarea> </fieldset> <fieldset class="bold"> *All fields Required</fieldset> <script type="text/javascript"> var RecaptchaOptions = { theme : 'clean', tabindex : 0 }; </script> <noscript><p>Please enable javascript in your browser to post this form</p></noscript> <?php require_once('recaptchalib.php'); $publickey = ""; echo recaptcha_get_html($publickey, $error); ?> <p><input id="submit" name="submit" type="submit" value="Submit" /></p></form> I am using xhtml strict. If I place it after the form tag, will it still work if javascript is disabled? Ok, I have an ajax form that uses "onkeyup" in an input to display dynamic data. I want to change the value of the input to "Enable javascript" if the user has javascript disabled. Any suggestions on how to accomplish this? Thanks, somniculouse Hi, I've got this bit if JavaScript that loads a Flash applet. It also has a noscript tag in case the user has JavaScript turned off. Works great in all browsers I've tried, but it doesn't work at all in IE8 (nor IE7 emulated). Even the noscript content isn't showing up. W3C validator shows no issues. No little exclamation point warning in IE's bottom-left corner. I've even tried lowering the browser security with no change -- but that wouldn't have been a good solution if it had worked anyway; I can't tell my visitors to lower their browser security. Any ideas of suggestions? Thanks for any help! You can see the page he http://www.girlscoutsmoheartland.org/test/vcattest.html If you look at the source, that's all there is to it. No undisplayed server-side scripting. And here's the code if you don't want to visit the page: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> <script type="text/javascript" src="http://www.myvirtualpaper.com/js/miniflipper.js"></script> </head> <body> Below this line should be either a Flash applet, or a link if JavaScript is unavailable:<br> <noscript><a href="http://www.myvirtualpaper.com/doc/gs_missouri_heartland/girlscout2010catalog/">Click here to view all pages.</a></noscript> <script type="text/javascript"> var miniFlipperOptions = {'uid' : 'bfbe7aa59d'}; MVP_printMiniflipper(miniFlipperOptions); </script> <br> Above this line should be the mentioned item option. </body> </html> I have a 'show more' link on my page and wish to allow users who disable javascript to automatically see this normally hidden div as the link obviously will not work. is this possible ? the info in the hidden div will be taken from MySQL databases. Code: <div><!-- start of div2 --> <div class="floatleft"><a href="#" id="textbox-show" class="showLink" onclick="showHide('textbox');return false;">Show more</a> </div> <div><!-- start of div3 --> <div id="textbox" class="more"> <div class="formtitles">Show more <a href="#" id="textbox-hide" class="hideLink" onclick="showHide('textbox');return false;">Hide this content</a> </div> <div> <div class="containercolour3"> <div class="rtopcolour3"> <div class="r1"></div><div class="r2"></div><div class="r3"></div><div class="r4"></div> </div> <div class="formspacer">Hidden text</div> <div class="rbottomcolour3"> <div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div> </div> </div> </div> </div> <!-- end of div3 --></div> <!-- end of div2 --></div> Hi, I'm trying to redirect my users to their profile, but can't figure out how to put the function into the link. sethighlightedValue(); is a function that returns the users username. Is there anyway else to do this? Here's what I got: Code: case RETURN: window.location = "profile.php?user='setHighlightedValue();'"; this.setHighlightedValue(); bubble = false; break; what wrong, it just adds the website to the end of the address bar, and it doesnt redirect???help please <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <div> <h1>hello</h1> <form onsubmit="return go();"> <select name="website" id="website"> <option value="http://www.google.com/">google.com</option> <option value="www.yahoo.com">yahoo.com</option> </select> <script type="text/javascript"> function go() { var s = getElementById("website"); window.location = s.options[s.selectedIndex].value; return false; //prevents the form from being submitted to the server. } </script> <input type="submit"> </form> </div> </body> </html> Hey all im new to the forum as i have just started playing round with javascript but anyway i have this code PHP Code: setTimeout(top.location='profilec.php?id=' + id,4000); and when executed the time delay is not taken into account at all and completly ignored. If i remove the id var from the code and just have PHP Code: setTimeout(top.location='profilec.php?id=',4000); its fine can anyone tell me why this is happening and if there is a solution :-) thanks before hand mike Hi, I'm trying to change a piece of code I found in a scipt: Code: if (errors == null) { jQuery('#requestform') .hide() .html('<div class="thankyou"><h1>Merci</h1><p>Nous reviendrons vers vous.</p></div>') .show(); } Instead of the .html () I would like to redirect to another webpage of my website, in the same window. Anyone can help me? Thanks. i'm a total noob with java and can't seem to figure this out. i want to add a bit on to the current url : this is the code i'm using , it just keeps adding... Code: window.location=(window.location+"?p=62"); am i even doing this right.. any help appreciated.. Hello, I'm new to Javascript Programming. Therefore be patient with me. I'm looking for a script where if someone goes to www.site1.com this site will automatically go to www.site2.com by simulating a mouse click. I've looked everywhere on the internet for a solution but had no luck. Any assistance will be greatly appreciated. Thanks Velvet. Hi, I want to do a redirect count so that the user can see the count going down. for example, I want them to be able to see the following. You will be redirected in 5 seconds. The user should be able to see the count going down from 5 to 4 to 3 to 2 to 1 and then they are redirected. I can get the page to redirect after 5 seconds but I want the user to be able to see it count down. Thanks in advance for your help I want to be able to put up files and assign passwords to individuals so that they can access one of those files but not all. In other words person A enters password & is redirected to file A; person B enters password & is redirected to file B, etc. Anyone have an example or know where I can get an example of a script like this? I am not a programmer so the simplier the better. Thanks
Hello All, I have some javscript running on a page to automatically redirect the user to the SSL secured page (https). The code I have works fine when there is www. in front of the site name, but if you just type the site name without the url the code doesn't work. Any suggestions? Thank so much. Code: <script language="javascript" type="text/javascript" > // This is the hostname that will trigger enforcement of redirection. var enableRedirect = true; // This is the hostname that will trigger enforcement of redirection. var externalHostname = "www.exelonenergy.com"; // This is the reconstructed URL if the current URL contains the externalHostname: var redirectURL = "https://" + externalHostname + window.location.pathname; // If the URL contains the externalHostname specified above, // and the protocol in plain http:, then redirect to the https: equivalent: if (enableRedirect == true) { if (window.location.hostname.indexOf(externalHostname) >= 0) { if (window.location.protocol == "http:") { window.location.href = redirectURL; } } } </script> I was wondering how I could redirect from one div to another div after " x " seconds on the same page.. Is this possible? So like basically: Index page: > Shows div1, after x seconds shows div2 etc.. Hello, I need to improve an existing JavaScript redirect by adding a second redirect based on information contained in the URL. First I will outline the situation, then the specifics: I designed a Realtor website using Joomla 1.5 a few years ago. I will call this SITE-1. The site, SITE-1, displays real estate listing from another site (SITE-2) using iFrames. So the listings from SITE-2 appear to be integrated into the pages of SITE-1. Someone shopping for real estate signs up to be notified of new listings. A new listing comes out and an email is sent to the user with a link to the listing - only the link to the listing is located on SITE-2. So I have been using a JavaScript redirect on SITE-2 that asks the question - "is this in an iFrame" ... if no - redirect to SITE-1 and iframe the results. SITE-1 is ready to receive and parses the new URL: Code: <script language="JavaScript"> <!-- // Start if (window == top) { tops = top.location.href location.replace('http://www.SITE-1.com/index.php?option=com_content&view=article&id=42&Itemid=137&iframe='+tops); } // End --> </script> Now, I have a new problem. I don't have access to SITE-2, I only get to submit a template to them. One of the possible links sent to users from SITE-2 contains a variable in the URL: &id=, followed by a 3 digit number. So the full URL might look like this: http://www.site-2.com/index.php?pg=delacct&id=570 I cannot redirect this to the normal page on SITE-1 because Joomla already uses id=, and it just gets confused and drops a 404 page. Instead I need the code I posted above, to FIRST check for id=. If it exists - go to PAGE-A. If not - then do what the script already does as posted above (we'll call that PAGE-B). Can anyone help? (hopefully I explained that so it can be understood) Thanks, --Kevin I'm trying to figure out how to use an javascript function to redirect without using <body onload>. Normally I use this: Code: <META HTTP-EQUIV="Refresh" Content="0; URL=ajax.php?page=mypage"> But since I'm using ajax, and only want to redirect tha ajax part, the above can not be used... When I have a hyperlink to go to a page in ajax it looks like this: Code: <a href="#" onclick="load('ajax.php?page=mypage','contentarea');return false;"> Is there anyway that I can have the ajax part set into the META HTTP-EQUIV="Refresh" or is there an other way to do this? Thanks in advance... Hello, I am new on forum and javascript. I have got a query for dynamic geo location javascript. I would like to make a page which redirect to another page based on user REGION. Ex. If user from EMEA then page1.html, if user from APAC then page2.html, if user from Other region then page3.html Hope someone will share their ideas with an example to achive this. Thanks Hi Guys... I have a slight problem... I'm trying to do a redirect countdown within an iframe and it keeps putting the new page inside the iframe and not opening a new maximized window/tab outside of the iframe. Here is the code for example just going to yahoo: Code: <HEAD> <SCRIPT LANGUAGE="JavaScript"> var start=new Date(); start=Date.parse(start)/1000; var counts=2; function CountDown(){ var now=new Date(); now=Date.parse(now)/1000; var x=parseInt(counts-(now-start),10); if(document.form1){document.form1.clock.value = x;} if(x>0){ timerID=setTimeout("CountDown()", 100) }else{ location.href="http://www.yahoo.com" } } </script> <SCRIPT LANGUAGE="JavaScript"> <!-- window.setTimeout('CountDown()',100); --> </script> </HEAD> <BODY> <center> <FORM NAME="form1"> You are being redirected in <INPUT TYPE="text" NAME="clock" SIZE="2" VALUE="10"> seconds. </FORM> </center> </Body> Here's the kicker... If I replace yahoo.com with some web sites it works PERFECTLY fine and replaces the page with the new page... why is that? Hi, I have a form in which i have a dropdown list and a submit button. I want to code so that when users select the value from the dropdown list, it should redirect then to the specified page. For instance i have the value, "car", "House" and "pets" in my dropdown listbox, if a use click on "car" it should redirect them to the car page. I have done the following code, but something seems not to work Code: <script type="text/javascript"> function move(){ if (document.sell.cat.value == 'Cars'){ window.location = 'http://www.yourdomain.com' } </script> and in the submit button am calling the function move() Code: <input type="submit" name="button2" id="button2" value="Search" onclick="move()"/> my form name is sell and the dropdown list menu is cat. Thanks |