I have some code that allows one to move an image by clicking links (move left, move right etc) - the code works in IE but not in Google Chrome - therefore I have added to the JavaScript a check for this via g = (document.getElementById) ? 1 : 0; and then I'm accounting for this in the function for example by utilizing the syntax as such to no avail:
if (g) document.getElementById('imageTwo').innerHTML.left += 5;
I tried this also with
if (g) document.getElementById('imageTwo').left += 5;
Full code snippet is below:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Layer Test</title>
<style>
.container {
position: relative;
}
.imageOrig {
position: absolute;
}
.image {
position: absolute;
}
.imageOne {
z-index: 0;
}
.imageTwo {
z-index: 1;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
opacity: 0.5;
}
.navigation {
width:430px;
height:211px;
}
</style>
<script language="javascript">
n = (document.layers) ? 1 : 0;
ie = (document.all) ? 1 : 0;
g = (document.getElementById) ? 1 : 0;
function moveleft() {
if (n) document.imageTwo.left += 5;
if (ie) imageTwo.style.posLeft += 5;
if (g) document.getElementById('imageTwo').innerHTML.left += 5;
}
function moveright() {
if (n) document.imageTwo.left -= 5;
if (ie) imageTwo.style.posLeft -= 5;
if (g) document.getElementById('imageTwo').innerHTML.left -= 5;
}
function moveup() {
if (n) document.imageTwo.top -= 10;
if (ie) imageTwo.style.posTop -= 10;
if (g) document.getElementById('imageTwo').innerHTML.top -= 10;
}
function movedown() {
if (n) document.imageTwo.top += 10;
if (ie) imageTwo.style.posTop += 10;
if (g) document.getElementById('imageTwo').innerHTML.top += 10;
}
function reset() {
if (n) document.imageTwo.left = 100;
if (ie) imageTwo.style.posLeft = 100;
if (g) document.getElementById('imageTwo').innerHTML.left = 100;
if (n) document.imageTwo.top = 100;
if (ie) imageTwo.style.posTop = 100;
if (g) document.getElementById('imageTwo').innerHTML.top = 100;
}
</script>
</head>
<body>
<div class="container">
<table border="0">
<tr>
<td>
<img src="images/sample image1.jpg" class="imageTwo image" id="imageTwo"><br/>
</td>
<td class="navigation">< </td>
<td class="navigation">
<a href="#" onclick="moveright();">Move image right</a><br/>
<a href="#" onclick="moveleft();">Move image left</a><br/>
<a href="#" onclick="moveup();">Move image up</a><br/>
<a href="#" onclick="movedown();">Move image down</a><br/>
<a href="#" onclick="prev();"><img src="back.jpg" border="0" /></a>
<a href="#" onclick="next();"><img src="next.jpg" border="0" /></a>
</td>
</tr>
</table>
</div>
</body>
</html>