The Reveller The Reveller - 3 months ago 10
HTML Question

Can you set the name of the window your website is in without opening it in a new window?

Our website could be opened from a number of locations such as website links bookmarks etc and therefore I have no control over the target attribute of inbound links.

Once on our website, is it possible to set the winodw's name?

I found the solution below but can't get it to work.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js?ver=2.1.0'></script>
<script>
$(window.name = 'portal';)
</script>

<a href="http://www.inty.com" target="portal">This window</a>
<a href="http://www.inty.com" target="_blank">Another window</a>

</body>
</html>


The reason I want to do this is so that when a user does a password reset via email, they wont end up with our site in 2 separate windows.

p.s. I don't mean the title tag

Answer

You use:

window.name = "myWindowName";