I am facing some limitations with the program, therefore it would be preferable if
the solution does not require JQuery, as mentioned earlier. There are certain
restrictions that need to be taken into consideration.
My objective is to:
Dynamically change an image using JavaScript. (Completed)
Ensure that each image redirects to a different link when clicked by the user. (Need assistance!)
Below is the code I am currently working with:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var image1=new Image()
image1.src="image_1.jpg"
var image2=new Image()
image2.src="image_2.jpg"
var image3=new Image()
image3.src="image_3.jpg"
var step = 1
function slideit(){
document.images.slide.src=eval("image"+step+".src")
if(step<3) step++
else step=1
setTimeout("slideit()",2500)
}
slideit()
function inputhref() {
var href = 'https://www.google.ca/';
window.open(href)
}
</script>
</head>
<body>
<img src="image_1.jpg" name="slide" width="400" height="400"
onclick="inputhref()">