I have the following code at the moment.
<meta http-equiv="Refresh" content="0;URL=http://whatever.com/index.html">
I have the following code at the moment.
<meta http-equiv="Refresh" content="0;URL=http://whatever.com/index.html">
So my quastion is, how do you redirect someone to another site using javascript??
you simply don’t, it’s bad practice for multiple reasons that I don’t want to go into right now.
As I said before, use mod_rewrite in case you’re on an Apache server, if not find out the appropriate means for the server you’re using, e.g. by contacting your host.
What kind of server are you using? Is it Apache or IIS or what?
I want this index just to redirect visitors to another page depending on what address they are visiting.
So say that they are on the
www.example.se/test1/index.html -> www.randomSite.com/test1/index.html
www.example.se/test2/index.html -> www.randomSite.com/test2/index.html
www.example.se/test3/index.html -> www.randomSite.com/test3/index.html
So I want to take whats after www.example.se/(someText)/index.html
And redirect them
So as soon as the visitor enters the site www.example.se/test1/index.html, hes redirected to the www.randomSite.com/test1/index.html.
So my quastion is, how do you redirect someone to another site using javascript??
Like this
<html>
<head>
<title>Summary</title>
<script type="text/javascript">
function goToPath(){
var theUrlToGoTo = "www.randomSite.com";
var currentUrl = window.location.href;
var aPosition = currentUrl.indexOf("/");
var secondPos = currentUrl.indexOf("/", aPosition + 1);
for(i=aPosition; i< secondPos;i++){
theUrlToGoTo=(theUrlToGoTo + currentUrl.charAt(i));
}
theUrlToGoTo=theUrlToGoTo + "/index.html";
GoToThisURL(theUrlToGoTo);/*How do I go to this url in javascript??********/
}
</script>
window.onload = goToPath();
</head>
<body>
</body>
</html>
}
To quote c2UK - “You don’t”
Please look/post a thread in either the Server Managemen or [URL=“http://www.sitepoint.com/forums/forumdisplay.php?f=199”]Apache Configuration depending on what server you have.
Sorry my internet is wierd…
my quastion was how do i do something like this
I have the following code at the moment.
Say that i want it the URL to call a function in javascript.js called write();
can i do like this?
<script type="text/javascript" language="Javascript" src="javascript.js"></script>
<meta http-equiv="Refresh" content="0;URL="javascript:write();">
that redirects the user from the current page to a new page instantly. This method is not advisable and you should use 301 redirects set up in your htaccess file (assuming you’re on an apache server). head over to the apache config subforum for more info.
I dunno, it’s “redirecting” to the index.html page. Sounds like (again, assuming Apache) you want
DirectoryIndex index.html
http://httpd.apache.org/docs/2.0/mod/mod_dir.html
This allows whatever.com to transparently send visitors to whatever.com/index.html without anyone seeing the index.html at the end.
what do you want to achieve with a code like that?