Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6848917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:55:37+00:00 2026-05-27T00:55:37+00:00

So I’m writing an html file that is loaded locally by a UIWebView on

  • 0

So I’m writing an html file that is loaded locally by a UIWebView on the iPad. Each image in the page has a “touchend” event handler that pretty much changes the src of the image to another image file. When I do this, $(glovesImage).attr("src","gloves.png"); inside of the event, for some reason it’s arbitrarily changing its position and the positions of any other image elements below it in the HTML tree. Is there any reason for this?

<html>
  <head>
    <title>Index</title>
  </head>
  <body>
    <img id="backgroundImage" alt="" src="image445.jpg" />
    <img id="lockerImage" alt="" src="locker.png" />
    <img id="guyImage" alt="" src="guy.png" />
    <img id="capImage" alt="" src="cap.png" />
    <img id="maskImage" alt="" src="mask.png" />
    <img id="shieldImage" alt="" src="shield.png" />
    <img id="glovesImage" alt="" src="foldedGloves.png" />
    <img id="bootsImage" alt="" src="foldedBoots.png" />
    <img id="underGownImage" alt="" src="foldedUnderGown.png"/>
    <img id="gownImage" alt="" src="gown.png" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
    var guyImage;
    var capImage;
    var maskImage;
    var shieldImage;
    var gownImage;
    var underGownImage;
    var glovesImage;
    var bootsImage;
    var originalCapImageLocationX = 580;
    var originalCapImageLocationY = 80;
    var originalMaskImageLocationX = 720;
    var originalMaskImageLocationY = 80;
    var originalShieldImageLocationX = 650;
    var originalShieldImageLocationY = 70;
    var originalGownImageLocationX = 750;
    var originalGownImageLocationY = 300;
    var originalUnderGownImageLocationX = 600;
    var originalUnderGownImageLocationY = 200;
    var originalGlovesImageLocationX = 560;
    var originalGlovesImageLocationY = 400;
    var originalBootsImageLocationX = 620;
    var originalBootsImageLocationY = 400;
    var originalGuyImageLocationX = 150;
    var originalGuyImageLocationY = 0;

    $(document).ready(function () {
        //Position the background and locker in the right positions
        var backgroundImage = $("#backgroundImage");
        backgroundImage.offset({ left:0, top:0});
        var lockerImage = $("#lockerImage");
        lockerImage.offset({left:$(document).width() - lockerImage.width(), top:0});
        //Prevent the webview from scrolling
        document.body.addEventListener("touchmove", function (event) {
            event.preventDefault();
        }, false);
        //Get referneces of the images in html
        guyImage = $("#guyImage");
        capImage = document.getElementById("capImage");
        maskImage = document.getElementById("maskImage");
        shieldImage = document.getElementById("shieldImage");
        gownImage = document.getElementById("gownImage");
        glovesImage = document.getElementById("glovesImage");
        bootsImage = document.getElementById("bootsImage");
        underGownImage = document.getElementById("underGownImage");

        //Add the drag event listeners to the images
        capImage.addEventListener("touchmove", function (event) {
            if (event.targetTouches.length == 1) {
                var touch = event.targetTouches[0];
                moveImageCenterTo(touch.pageX, touch.pageY, $(capImage));
            }
        }, false);

        maskImage.addEventListener("touchmove", function (event) {
            if (event.targetTouches.length == 1) {
                var touch = event.targetTouches[0];
                moveImageCenterTo(touch.pageX, touch.pageY, $(maskImage));
            }
        }, false);

        shieldImage.addEventListener("touchmove", function (event) {
            if (event.targetTouches.length == 1) {
                var touch = event.targetTouches[0];
                moveImageCenterTo(touch.pageX, touch.pageY, $(shieldImage));
            }
        }, false);

        gownImage.addEventListener("touchmove", function (event) {
            if (event.targetTouches.length == 1) {
                var touch = event.targetTouches[0];
                moveImageCenterTo(touch.pageX, touch.pageY, $(gownImage));
            }
        }, false);

        underGownImage.addEventListener("touchmove", function (event) {
            if (event.targetTouches.length == 1) {
                var touch = event.targetTouches[0];
                moveImageCenterTo(touch.pageX, touch.pageY, $(underGownImage));
            }
        }, false);

        glovesImage.addEventListener("touchmove", function (event) {
            if (event.targetTouches.length == 1) {
                var touch = event.targetTouches[0];
                moveImageCenterTo(touch.pageX, touch.pageY, $(glovesImage));
            }
        }, false);

        bootsImage.addEventListener("touchmove", function (event) {
            if (event.targetTouches.length == 1) {
                var touch = event.targetTouches[0];
                moveImageCenterTo(touch.pageX, touch.pageY, $(bootsImage));
            }
        }, false);

        //Add the finger up events to the images
        capImage.addEventListener("touchend", function (event) {
            if (event.changedTouches.length == 1) {
                var x = getCenterLocationX($(capImage));
                var y = getCenterLocationY($(capImage));
                if (isWithinGuysHead(x, y)) {
                    moveImageToLocation(getGuysHeadLeft() - 8, getGuysHeadTop(), $(capImage));
                } else {
                    moveImageCenterTo(originalCapImageLocationX, originalCapImageLocationY, $(capImage));
                }

            }
        }, false);

        shieldImage.addEventListener("touchend", function (event) {
            if (event.changedTouches.length == 1) {
                var x = getCenterLocationX($(shieldImage));
                var y = getCenterLocationY($(shieldImage));
                if (isWithinGuysHead(x, y)) {
                    moveImageToLocation(getGuysHeadLeft() - 10, getGuysHeadTop() - 20 + (getGuysHeadBottom() / 2), $(shieldImage));
                } else {
                    moveImageCenterTo(originalShieldImageLocationX, originalShieldImageLocationY, $(shieldImage));
                }

            }
        }, false);

        maskImage.addEventListener("touchend", function (event) {
            if (event.changedTouches.length == 1) {
                var x = getCenterLocationX($(maskImage));
                var y = getCenterLocationY($(maskImage));
                if (isWithinGuysHead(x, y)) {
                    moveImageToLocation(getGuysHeadLeft() - 5, getGuysHeadTop() - 5 + (getGuysHeadBottom() / 2), $(maskImage));
                } else {
                    moveImageCenterTo(originalMaskImageLocationX, originalMaskImageLocationY, $(maskImage));
                }

            }
        }, false);

        gownImage.addEventListener("touchend", function (event) {
            if (event.changedTouches.length == 1) {
                var x = getCenterLocationX($(gownImage));
                var y = getCenterLocationY($(gownImage));
                if (isWithinGuysBody(x, y)) {
                    moveImageToLocation(getGuysXLocation() + 5, getGuysHeadBottom() - 8, $(gownImage));
                } else {
                    moveImageCenterTo(originalGownImageLocationX, originalGownImageLocationY, $(gownImage));
                }

            }
        }, false);

        underGownImage.addEventListener("touchend", function (event) {
            if (event.changedTouches.length == 1) {
                var x = getCenterLocationX($(underGownImage));
                var y = getCenterLocationY($(underGownImage));
                if (isWithinGuysBody(x, y)) {
                    $(underGownImage).attr("src", "underGown.png");
                    moveImageToLocation(getGuysXLocation() + 25, getGuysHeadBottom() - 8, $(underGownImage));

                } else {
                    $(underGownImage).attr("src","foldedUnderGown.png");
                    moveImageCenterTo(originalUnderGownImageLocationX, originalUnderGownImageLocationY, $(underGownImage));
                }

            }
        }, false);

        glovesImage.addEventListener("touchend", function (event) {
            if (event.changedTouches.length == 1) {
                var x = getCenterLocationX($(glovesImage));
                var y = getCenterLocationY($(glovesImage));
                if (isWithinAnyGuysHand(x, y)) {
                    $(glovesImage).attr("src","gloves.png");
                    moveImageToLocation(getGuysXLocation(), getGuysHandsTopEdge() - 28, $(glovesImage));
                } else {
                    $(glovesImage).attr("src","foldedGloves.png");
                    moveImageCenterTo(originalGlovesImageLocationX, originalGlovesImageLocationY, $(glovesImage));
                }
            }
        }, false);

        bootsImage.addEventListener("touchend", function (event) {
            if (event.changedTouches.length == 1) {
                var x = getCenterLocationX($(bootsImage));
                var y = getCenterLocationY($(bootsImage));
                if (isWithinGuysFeet(x, y)) {
                                    $(bootsImage).attr("src","boots.png");
                    moveImageToLocation(getGuysFeetLeftEdge() + 5, getGuysFeetTopEdge() - 5, $(bootsImage));
                } else {
                                    $(bootsImage).attr("src","foldedBoots.png");
                    moveImageCenterTo(originalBootsImageLocationX, originalBootsImageLocationY, $(bootsImage));
                }

            }
        }, false);

        //Move the images to their original locations
        moveImageCenterTo(originalCapImageLocationX, originalCapImageLocationY, $(capImage));
        moveImageCenterTo(originalMaskImageLocationX, originalMaskImageLocationY, $(maskImage));
        moveImageCenterTo(originalShieldImageLocationX, originalShieldImageLocationY, $(shieldImage));
        moveImageCenterTo(originalGownImageLocationX, originalGownImageLocationY, $(gownImage));
        moveImageCenterTo(originalUnderGownImageLocationX, originalUnderGownImageLocationY, $(underGownImage));
        moveImageCenterTo(originalGlovesImageLocationX, originalGlovesImageLocationY, $(glovesImage));
        moveImageCenterTo(originalBootsImageLocationX, originalBootsImageLocationY, $(bootsImage));
        moveImageToLocation(originalGuyImageLocationX, originalGuyImageLocationY, $(guyImage));
    });
</script>

I just posted the relevant code. Thanks in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:55:38+00:00Added an answer on May 27, 2026 at 12:55 am

    So the problem ended up being in the css. By default the position for each item is “static”, so all I did was change it to “absolute” so that when the src of the image changes and thus its width and height, it doesn’t mess with the position of the other elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.