I would like to create a page which redirects to several pages when it is pressed.
I have written the following code in order to try and do it:
<html>
<head>
<meta http-equiv="refresh" content="0; url=http://www.example.com/a" />
<meta http-equiv="refresh" content="0; url=http://www.example.com/b" />
<meta http-equiv="refresh" content="0; url=http://www.example.com/c" />
</head>
</html>
On the web server log, I see that a request was only sent to "c".
Why is that?
And how can I create an HTML page with multiple redirects?
You will inevitably need to use javascript.
<script>
function redirect(){
windows.open("http://www.example.com/a")
windwos.open("http://www.example.com/b")
windwos.open("http://www.example.com/c")
}
</script>
<body onload="redirect()">
Didn't test but should suffice
I am not sure you understand, when refresh means. Refreshing with 0 means the browser is immediately redirected to the address provided. As far as one browser tab can only show one web page, your example cannot work.
You need to consider using Popups or alike to show the user several pages at one time.
Related
I have implemented ViewExpiredException handling as described here and here (Thank you #BalusC and team). It is working properly. However, the error page flashes by so quickly that the user is not informed that he/she has been redirected due to a session timeout. Is there a way to slow things down a bit?
Here is the error page:
<html lang="en">
<head>
<title>Session Expired</title>
<meta http-equiv="refresh" content="0;url=#{request.contextPath}/index.xhtml" />
</head>
<body>
<h1>Session Expired</h1>
<h3>You will be redirected to the starting page</h3>
<p>Click here if the redirect didn't work or if you are impatient.</p>
</body>
The behaviour is exactly as you tell it to behave
<meta http-equiv="refresh" content="0;url=#{request.contextPath}/index.xhtml" />
The content="0 in there means: "Don't wait but redirect immediately". Changing the 0 to 10 will make it wait 10 seconds,
<meta http-equiv="refresh" content="10;url=#{request.contextPath}/index.xhtml" />
Effectively this is not jsf related at all but plain html. Same would have been a problem with a normal 404 error page
I need to have a HTML file. When user clicks on it, it will open a site, say, example1.com and stay there for 2 seconds, then it will redirect to another site, say, example2.com. How can I achieve it?
I do some search and try the following way. It doesn't work. Can somebody help? Thank you very much.
Edited: The reason behind it is, user has to visit the first site to get cookie and then open the second site. Ideally, user should not see the first site. If HTML can't do that, what would be a good way to achieve that? I don't have access to server of either site.
<html>
<head>
<title>A web page that loads two sites in order</title>
<meta http-equiv="refresh" content="2; URL=https://www.example1.com">
<meta http-equiv="refresh" content="2; URL=https://www.example2.com">
</head>
<body>
Please wait...
</body>
</html>
I am reading a Servlet "HellowWorld" tutorial. The servelet is defined in a HelloWorldServelet.java class. Super simple to output "Hell world" message to the client request. The only html file is "index.html" below. I don't understand how the meta tag works. As I run the application in the web server, it automatically this page with the URL:
http://localhost:8080/helloworld/HelloWorld
How the attributes "http-equiv" and "content" work together with the servelet?
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=HelloWorld">
</head>
</html>
The Refresh meta-tag automatically redirects the browser to the URL given after the specified amount of time.
Without seeing the tutorial you are using, I can't imagine why you would need to use it for your task.
https://en.wikipedia.org/wiki/Meta_refresh
"http-equiv" and "content"
they are used for adding message headers in http response .
For example http-equiv can be used to refresh the page.
if you specify something like this
<meta http-equiv="refresh" content="45">
you are instructing browser to refresh in every 45 seconds.
Other than refresh,you can use it to set cookies and etc.
I have a simple place-holder html-file that I would want to use the header meta tag to redirect automatically. The target is a symolic link (linux) that points to a git-repo directory.
<meta http-equiv="refresh" content="0; url="universitetet/">
However this simply reloads itself. Giving absolute path does so too.
However, using the javascript solution works (and also normal links work fine).
<script language="javascript">
window.location = "universitetet/";
</script>
Get rid of the extra " inside the content attribute.
<meta http-equiv="refresh" content="0; url=universitetet/" />
Side note: Always provide a plain HTML link (Link), in case the user has disabled meta redirection and/or JavaScript.
This code:
<meta content="0; url=(YOUR_LINK)" http-equiv="REFRESH">
Working with me, btw your code have issue with quotations: here content="0; url="universitetet/".
I have a site hosted on a commercial provider and all site were developed on /portal folder.
Until today I redirect the site using frameset:
<html>
<head>
<title>Titulo</title>
<meta name="google-site-verification" content="xxx" />
<meta http-equiv="Content-Language" content="pt-br">
<meta name="description" content="xxxx">
</head>
<FRAMESET>
<FRAME SRC="http://www.test.com.br/portal" NORESIZE>
<body></body>
</FRAMESET>
</html>
Now, the host provider suggests me to use:
<script>window.location='http://www.test.com.br/portal';</script>
Is this faster or better than the frameset approach ?
Is Google or other search engine will continue to search for the content?
You have different ways to redirect to another page. If you're using a server-side language like php you can use this (before the headers has been sent):
header("Location: http://www.test.com.br/portal");
using HTML you can do this:
<meta http-equiv="refresh" content="0;url=http://www.test.com.br/portal">
Using Javascript you can do this:
<script>window.location='http://www.test.com.br/portal';</script>
The best way, in my opinion, is the first because of you can also specify the type of redirect (permanent or temporary) and this is better from a SEO point of view. Google and the other search engines will be able to crawl your page easily if you choose the first solution.
Just add this tag to the head section
<meta http-equiv="refresh" content="0; URL=http://www.test.com.br/portal"/>
For some reasons it's better than using framesets.
In addition to
<script>window.location='http://www.test.com.br/portal';</script>
you can put a link to that page into your HTML body, something like this:
<p>You will now be redirected to another page.<br/>
If it didn't happen, use this link:
http://www.test.com.br/portal</p>
But the solution with php's header function (Aurelio De Rosa's answer) is better indeed.