Creating the function
What I have done here is created a custom function called showPopup(). This will accept a variable called ‘url’. Inside the function I defined a new variable called ‘newwindow’. This is equal to the open() method which will open a new browser window. Finally I used the focus method which will ensure that the new window is sent to the front.
Creating the Link
<a href="http://www.youtube.com/embed/0Z9rP7CBs_Y" onclick="showPopup(this.href);return(false);">Web design London</a>
Above is an example of a link that calls the showPopup function. To do this I used the onclick attribute. Because the showPopup function accepts one value, I passed in “this.href” which is equal to the link “http://www.youtube.com/embed/0Z9rP7CBs_Y””. Finally I disabled the default link action by adding return(false).
To get a youtube link, simply click embed underneath your chosen video and copy the url specified. Alternatively you may wish to use your own video player link. Either should would work fine. I hope you found this web design tutorial useful.