I have a problem with redirecting with javascript to a different page upon the click on a <td>
. For my websites I use the <base href="">
tag as a starting point for my links.
So consider this code:
<!doctype html>
<html lang="en"><head>
<meta charset="utf-8"/>
<title>Login</title>
<base href="http://www.mysite.com/MyWebsite/manage/" />
special reference to <base href="http://www.mysite.com/MyWebsite/manage/" />
and consider this jQuery:
//Set row clicking
$('table#alerts_table').on("click", "td", function () {
var alert_id = $(this).closest('tr').find('input[type=checkbox]').val();
var href = 'alerts/alert.php?id=' + alert_id;
if (href) { window.location.href = href; }
});
special reference to
var href = 'alerts/alert.php?id=' + alert_id;
if (href) { window.location.href = href; }
and consider that my current position on the website is already in the folder called alerts as follows: http://www.mysite.com/MyWebsite/manage/alerts/index.php
I want to move from index.php to alert.php.
On chrome all works as expected i.e. the base href http://www.mysite.com/MyWebsite/manage/
is concatenated to alerts/alert.php?id=1
and I am redirected accordingly.
However in IE the folder alerts is doubled: http://www.mysite.com/MyWebsite/manage/alerts/alerts/alert.php?id=1
This means that it is not taking the base URL from the base tag but it is using relative paths.
Any ideas?
you may use:
function. you will not reqire to use the base option. it will be redirected to page or subdirectory present in the same directory.