Reputation: 11052
I have to open two link within a same tab using JavaScript and HTML:
<script type="text/javascript">
go(){
windows.open('http://www.yahoo.com');
}
</script>
a href="https://mail.google.com/mail/u/0/?logout&hl=en-GB"onclick = "go();">click me</a>
What I want; when someone clicked on click me hyperlink then it should automatically runs sign out link of Gmail in background without any alert and redirect the automatically link which is in windows.open('http://yahoo.com');
.
Upvotes: 0
Views: 1628
Reputation: 1601
Algorithm would be:
Ok, whole test page content would be:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test</title>
<script type="text/javascript">
function go() {
var oImg=document.createElement("img");
oImg.setAttribute('src', 'https://mail.google.com/mail/u/0/?logout');
oImg.setAttribute('alt', 'na');
oImg.setAttribute('height', '1px');
oImg.setAttribute('width', '1px');
document.body.appendChild(oImg);
var t=setTimeout("goOn()",1500);
}
function goOn() {
window.location.assign("http://yahoo.com");
}
</script>
</head>
<body>
<p><a href="#" onclick="go();return false;">superlink</a></p>
</body>
</html>
Have tested it in FFox - works fine : )
Upvotes: 2
Reputation: 3773
A best way is to create a assincronous call to logout from wherever you want
try use jQuery get method or this tutorial: http://www.xul.fr/en-xml-ajax.html
Upvotes: 0