i am trying to redirect users without javascript enabled to our help page (help.php), specifically the part that talks about enabling javascript (help.php#nojavascript).
however, my meta refresh is not working! it keeps on refreshing the same page! i tried redirecting to a different page with a .html extension instead, and that works, so why doesn't this work?
...
</script>
<!-- if user doesn't have JS enabled, take them to help page -->
<noscript>
<meta http-equiv="Refresh" content="3;url=help.php" />
</noscript>
</head>
...
Try to use an absolute path:
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html">
For one thing, try taking it out of the NOSCRIPT element. Browsers with scripting enabled are supposed to ignore everything inside NOSCRIPT.
i was including a file that redirected the user to home.php =( sorry!
Related
Is there a way/tool to visit a site in cron that is capable of following HTML Meta Tag Redirects?
A programmer wrote a feature that when hit through a browser returns
<html>
<head>
<!-- HTML meta refresh URL redirection -->
<meta http-equiv="refresh"
content="0; url='.$base_url.'/cache/'.($trip_index+1).'">
</head>
<body>
<p>The page has moved to:
'.$base_url.'/cache/'.($trip_index+1).'</p>
</body>
</html>';
In a browser that will take you from example.com/cache/1 to example.com/cache/2 automatically until all the steps are done. Then the client came back and also wanted it to be automated...
I can't use cURL even with the -L flag because it only follows redirects in headers like 301, not the HTML ones.
I then found out about links and that worked great from the CLI with something like links -html-auto-refresh 1 example.com/cache and finished to the end. But unfortunately it doesn't work in cron because the refresh is part of the rendering itself.
So is there a tool that will work from a cron task that will do this? Browser testing tools? Selenium? PhantomJS? Splash?
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to detect if JavaScript is disabled?
In my php application i need to check whether the javascript is turn on or not in browser. I have tried this <noscript><p>javascript is off<p></noscript> it's working fine.But i need to redirect to a page if javascript is OFF so developed like this
<noscript>
<?php header('Location: index.php');?>
</noscript>
But i/ts always redirecting to index.php, there is any way to do this.
your solution clearly cannot work, since php is executed before the page is served on client
you could instead do something like
<noscript>
<meta http-equiv="refresh" content="0;URL='http://example.com/'">
</noscript>
in the head of your document
<noscript><meta http-equiv="refresh" content="1;url=error.html"></noscript>
try this to redirect if JS is disabled
Php script runs independently of js
There are known issues with noscript
Instead do this:
<html>
<head>
<script>
window.location.href="javascriptEnabled.html";
/*Since javascript is enabled redirect to javascript based page*/
</script>
</head>
<body>
Showing Static Website since javascript is not enabled..
</body>
</html>
There is not a good way to do it, because without client side interactivity, you can not get information back from the client.
You could do something like this...
Set up a meta redirect to trigger after 5 seconds
use javascript to override the meta redirect
Therefore, if javasccript is enabled, you get to the javascript page, otherwise the non javascript page
It does redirect to index.php because the <?php header('Location: index.php');?> is processed by the server while the <noscript> is processed by the client ..
A correct way to do this is to set a cookie using javascript on the client, then check for the cookie's presence with php on the server, If the cookie does exist, then javascript is on, Else, it's off.
You could use a different approach here
Use the no javascript version as default version
Use a javascript redirect to the enhanced version
Remember it's better to not have separate versions of the site. You could progressive enhancement with libraries as http://modernizr.com/ or https://github.com/filamentgroup/enhance
is there way to reload a web-page, when javascript is disabled in the brwoser?
I mean, if the user visits the page first time, and has no javascript enabled, the page reloads with a get parameter like page.php?js=false.
Maybe, thanks for hints.
The only way you could force a page reload, without javascript, is by use of a meta refresh tag. However, this is the wrong way to go: better display that page for the javascript-deprived, and redirect those who DO have javascript to a more appropriate page instead.
<noscript>
<meta http-equiv="refresh" content="2;url=page.php?js=false" />
</noscript>
You can use <noscript> tag with refresh <meta> tag.
Adding to Sarfraz's post, you could do this, to match your request:
<noscript>
<meta http-equiv="refresh" content="2;url=page.php?js=false">
</noscript>
You can do it the other way around:
Assume javascript is not available, and
redirect using javascript to page.php?js=true.
I was using this code to reload the page, however I'd only tested it on Chrome and when I tried it on Firefox I realized it didn't work. How do I make it work in other browsers?
echo 'Reloading. <META HTTP-EQUIV="refresh" CONTENT="0">';
Thanks
Instead of pushing out invalid HTML, instead, send the actual header using PHP's header function.
header("Location: http://where.you/want/to/redirect.to");
If the page has already loaded (even partially), then this approach will not work -- in that case, either using JavaScript or the <meta> tag will do the trick -- just remember that the <meta> tag must be added to the <head> portion of your HTML file.
<script type="text/javascript">window.location.reload(true);</script>
What you are doing is telling the browser to refresh. However, the <meta> tag you are using is meant to be in the <head> part of the document. That is probably why Firefox isn't properly executing it.
If you instead use the blurb above, which is javascript, you can put that code virtually anywhere in the document and it will cause the page to refresh.
My guess is that it's not working because it's not in the <head> tag. Generate a properly formatted HTML document and it should work. But why in the world would you want to refresh the page after zero seconds?
I want to redirect the user to a certain page if he/she has javascript disabled. I tried this code:
<noscript><?php url::redirect('controller/method'); ?></noscript>
// url::redirect is much like the location header
to no avail...
How do I do this?
Since the headers have already been sent, you'll need to use standard HTML markup:
<noscript>
<meta http-equiv="refresh" content="0;url=noscript.html">
</noscript>
Trying this on both Firefox and IE seems to work well... With JavaScript enabled, the <meta> tag is ignored. When it is disabled, the browser redirects to noscript.html.
There is no way to do a redirect based on if javascript is disabled. Why not do the opposite - redirect if javascript is enabled?
<script>
window.location = "...";
</script>
You can't use meta refresh tag then remove it using Javascript because the browser is set to redirect upon reading the meta refresh tag and it's too late for JS to manipulate it.
The only way is to either do what Daniel suggested, or to show up a link when there's no Javascript:
<noscript>
Click here to continue
</noscript>
Or you can try to fail gracefully: Do you plan for javascript being off?
Add this as the first element in your body, style it to suit, and perhaps offer a link inside of it to a noscript page:
<div onload="return false;">
<!-- PAGE CONTENTS -->
</div><noscript>JAVASCRIPT IS REQUIRED TO VIEW THIS PAGE</noscript>
I use a more verbose method of this (that basically makes it appear as a modal dialog and all pretty) on pages where a client does not allow me to use more compatable means. I've tested in IE6+ and all other major browsers with great success.