Looking to launch a website from a desktop hyperlink? JavaScript won't cut it — you need to use C# for that task. If you're interested in opening a URL in a popup window, check out my step-by-step guide:
There are two different approaches to this. You could include `TARGET="_blank"` in the anchor tag, but this method simply opens a new browser window that covers up the old one entirely.
Sometimes, though, displaying a small popup window on top of the main browser window is more effective. This type of small window is commonly referred to as a popup.
I'll begin by showing you the basic syntax for creating a popup, followed by an explanation of the script along with a list of common arguments you can apply to a popup and how to handle focus issues.
Additionally, I will introduce a new method for adding popup functionality to a link; this approach is favored due to its cleaner implementation compared to the traditional method.
Finally, I'll touch upon the challenges of directly inserting content into the popup, particularly the confusion surrounding the true URL of the popup.
To set up a popup, here's the necessary script:
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150,menubar=no, scrollbar=no, sizeable=no');
if (window.focus) {newwindow.focus()}
return false;
}
// -->
</script>
To link to the popup, use the following code:
<a href="popupex.html" onclick="return popitup('popupex.html')"
>Link to popup</a>
Best of luck!