When redirect to my home page I have an infinite loop. For example is then when redirect using javascript url = 'home/request_verification' ; window.location = url;
my url now bees then and so on. It always added home class.
I just used this script
function checkCookie() {
var mob_tel=getCookie("mob_tel");
if (mob_tel!=null && mob_tel!="") {
//alert("Wele again " + mob_tel);
url = "home/test";
window.location = url;
//window.location.href('home/checkbalance');
} else {
set_name("");
}
}
then in my body
<body onload="checkCookie()">
...........
................
</body>
Help anyone..
When redirect to my home page I have an infinite loop. For example is http://mydomain. then when redirect using javascript url = 'home/request_verification' ; window.location = url;
my url now bees http://mydomain./home/request_verfication then http://mydomain./home/home/request_verification and so on. It always added home class.
I just used this script
function checkCookie() {
var mob_tel=getCookie("mob_tel");
if (mob_tel!=null && mob_tel!="") {
//alert("Wele again " + mob_tel);
url = "home/test";
window.location = url;
//window.location.href('home/checkbalance');
} else {
set_name("");
}
}
then in my body
<body onload="checkCookie()">
...........
................
</body>
Help anyone..
Share Improve this question asked Feb 1, 2012 at 7:11 Wondering CoderWondering Coder 1,70211 gold badges31 silver badges51 bronze badges2 Answers
Reset to default 4home/test
is a relative url. You're probably in need of an absolute url /home/test
.
The difference is that home/
looks for home
in the current folder, but /home
looks for home
in the root of your website.
You got to use the absolute path, else the infinite loop continues. So, use
url = "http://mydomain./home/test";
window.location = url;
If you do not want to hardcode the root URL ie.,http://mydomain., try getting the root directory of the site from the server side like $_SERVER["HTTP_HOST"] in PHP as shown below:
url = "http://"+"<?php echo $_SERVER['HTTP_HOST'];?>"+"/home/test"; (for localhost) and
url = "<?php echo $_SERVER['HTTP_HOST'];?>"+"/home/test"; (for urls already containing http://)
window.location = url;
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745413216a4626626.html
评论列表(0条)