We can open hyperlink in new window using javascript.
lets consider you have the following hyperlink
Now add the following javascript code
The above javascript opens the new window when you click on the hyperlink.
Note: You have to specify the height and width of the new window. Otherwise it opens a new tab instead of new window.
In this way we can open the hyperlink in new window using javascript.
lets consider you have the following hyperlink
<a class="link" onclick="openWindow();"> open me in new window </a>As we are not using href attribute above hyperlink is shown as plain text. So use below styles to make it look as a hyperlink
.link { color: blue; cursor: pointer; }
Now add the following javascript code
function openWindow() { window.open('http://coding-issues.com', '', 'width=950,height=700'); }
The above javascript opens the new window when you click on the hyperlink.
Note: You have to specify the height and width of the new window. Otherwise it opens a new tab instead of new window.
In this way we can open the hyperlink in new window using javascript.
For more posts on Javascript visit: javascript
No comments:
Post a Comment