JavaScript onclick Instructions 1) The large image shall become a link to the sa
ID: 3844875 • Letter: J
Question
JavaScript onclick
Instructions
1) The large image shall become a link to the same website as the small image.
please help me for image 1 I have the image website as http://images.geeknative.com.s3.amazonaws.com/wp-content/uploads/2014/11/hanzo_presskit.png
and for image 2 i have the following website http://www.geeksandcom.com/wp-content/uploads/2015/06/Overwatch-Bastion.jpg
//Given this code//
<html>
<head>
<script>
function update(img)
{
document.getElementById('bigImg').src=img;
}
</script>
</head>
<body>
<img id="bigImg"/><br/>
<img src="1.jpg"/>
<img src="2.jpg"/>
</body>
</html>
Explanation / Answer
<html>
<head>
<script>
function update(img)
{
document.getElementById('bigImg').src=img;
}
function openURL()
{
var img = document.getElementById('bigImg').src;
var filename = img.replace(/^.*[\/]/, '');
if(filename == "1.jpg")
window.open("http://images.geeknative.com.s3.amazonaws.com/wp-content/uploads/2014/11/hanzo_presskit.png");
else
window.open("http://www.geeksandcom.com/wp-content/uploads/2015/06/Overwatch-Bastion.jpg");
}
</script>
</head>
<body>
<img id="bigImg"/><br/>
<img src="1.jpg"/>
<img src="2.jpg"/>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.