Reputation: 161
I am designing a webpage in which I want that when a user click on link a popup (new window) will open with a linked webpage. My code looks like below
<head>
<script language="javascript">
function win(add,w,h)
{
window.open(add,"","width="+w+",height="+h+",location=0,directories=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1,top=5,left=5");
window.location.reload();
}
</script>
</head>
<body>
<h1>Click to open link in new window</h1>
<ul>
<li><a href="#" class="Menu">Account Master</a>
<ul>
<li><a href="#" value="new.htm" onclick="win(this.value,600,450)">New</a></li>
<li><a href="#" value="mod.html" onclick="win(this.value,600,500)" >Modify</a></li>
<li><a href="#" value="del.html" onclick="win(this.value,600,500)">Delete</a></li>
<li><a href="#" value="view.html" onclick="win(this.value,600,500)">View</a></li>
</ul>
</li>
</ul>
</body>
In Firefox on clicking the link a popup appear but no link open(means it open only blank page) and in IE popup appear with link(/undefined) not the link provided link. I am unable to detect what is the error.
Upvotes: 0
Views: 4538
Reputation: 31
use this property of anchor tag target="_blank"
<a target="_blank" href="link.html">Link</a>
Upvotes: 0
Reputation: 1
Whether or not a link opens in a tab or window is determined by the user's browsers settings. You may want to rethink your end-solution.
Instead of displaying your linked page in a "new window/tab", try firing a modal. Here are some nifty modal effects that are easy to implement http://tympanus.net/Development/ModalWindowEffects/
Upvotes: 0
Reputation: 5444
Try this...
<head>
<script language="javascript">
function win(add,w,h)
{
window.open(add,"","width="+w+",height="+h+",location=0,directories=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1,top=5,left=5");
window.location.reload();
}
</script>
</head>
<body>
<h1>Click to open link in new window</h1>
<ul>
<li><a href="#" class="Menu">Account Master</a>
<ul>
<li><a href="new.htm" value="new.htm" target="_blank" onclick="win(this.href,600,450)">New</a></li>
<li><a href="mod.html" value="mod.html" target="_blank" onclick="win(this.href,600,500)" >Modify</a></li>
<li><a href="del.html" value="del.html" target="_blank" onclick="win(this.href,600,500)">Delete</a></li>
<li><a href="view.html" value="view.html" target="_blank" onclick="win(this.href,600,500)">View</a></li>
</ul>
</li>
</ul>
</body>
Upvotes: 1