How Do I Get My Picture Link To Open A Other File In An Iframe

- 1 answer

First of all, I'm new to this site and community. I have problems with my code, I want to open a specific html file by an onclick event on a photograph in an iframe. I want to use javascript for it and not <a href>

My code at this moment is as follows:

<script>function imageClick(url) {
window.location = url;}</script>

<img src='foto/SWPS4.jpg' width='120px' height='160px' onclick="imageClick('../PC.html')">  
<iframe frameBorder='0' border='3' id='GG' name='U1' Width='750px' height='900px'></iframe></html>

Secondly, I'm sorry for my bad grammar and the code being totally non-professional. I need the img to link to the iframe and open the file 'pc.html' I searched for quite a decent time, and can't find the proper answer.

At this moment the photo is clickable but doesn't open up any file, it just gives an error, 'file not found' and it doesn't open up in the iframe but on the page itself.



In the script tag:

function imageClick(url) {
    document.getElementById("GG").src = url;

You need to set the src attribute of the iframe.