I would like to append to an anchor the Target=”Popup” or Target=”_self” depending on window name.
I have two windows: Topic and Popup. Based on the current window I want to show the anchor results in one of the two windows.
From Topic window:
<a href=”A” target=”Topic”>
Or
<a href=”B” target=”Popup”>
From Popup window
<a href=”A” target=”Topic”>
Or
<a href=”B” target=”_self”> //don’t show smaller Popup in bigger Popup window
Also the IF statement is not working. The Else condition is never detected?
HTML:
<p>OnClick link to <a href="MoreInformation.htm" onclick="isPopup();">More Information</a>.</p>
JavaScript:
<script type="text/javascript">
var screenNam= window.name;
document.getElementById("winName").innerHTML=screenNam;
</script>
<script type="text/javascript">
var isPopup = function () {
if (winName = "Popup") {
var change = document.getElementsByTagName("a");
change.setAttribute("target", "_self");
}
else if (winName = "topic") {
var change = document.getElementsByTagName('a');
change.setAttribute('target', '_popup');
}
}
</script>