I'm a beginner in JavaScript and I need help figuring out how to achieve the following task.
Essentially, my goal is to have lines of code like this:
<a onclick="JavascriptFunction(0000000)"><img src="image1.png"></a>
The number within the parentheses, 0000000
, should be replaced with a unique code at the end of each YouTube video link. For example:
<a onclick="JavascriptFunction(0000000)"><img src="image1.png"></a>
<a onclick="JavascriptFunction(0000001)"><img src="image2.png"></a>
<a onclick="JavascriptFunction(0000002)"><img src="image3.png"></a>
The purpose of the JavaScript function is to open a popup window that has the same dimensions as a YouTube video and display the corresponding video based on the clicked thumbnail.
<iframe width="560" height="315" src="https://www.youtube.com/embed/0000000"></iframe>
What I really want is a page showcasing all our company's video reviews where clicking on a product's thumbnail opens a popup window with the relevant video. While I know I can create separate pages for each video and use onclick="popWin()"
, we have numerous videos to include on this page. Is there a way to have one page and dynamically update the code in the iframe
to show the correct video?
As this project is for a company, please note that I only have access to the HTML page and cannot make changes elsewhere. Adding a function in the head section is acceptable.