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

  • SEARCH
  • Home
  • 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 8190653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:43:28+00:00 2026-06-07T03:43:28+00:00

I am attempting to run javascript returned from a URL that I load in

  • 0

I am attempting to run javascript returned from a URL that I load in a UIWebView. The script takes an image and draws a dot on it to show a users location.

In Mobile Safari, UIWebView, and Google Chrome Mobile the image is not generated correctly and the dot is in the wrong place.

In Desktop Safari, Chrome, Opera Mini, and the Android version of my app it works fine.

I need assistance getting this to work in a UIWebView/Mobile Safari.

Problem 1: The call to context.drawImage() in the zoomIn() method generates the following error in the debug console for Mobile Safari: “Javascript Error. undefined. INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value.”

Problem 2: In the zoomOut() method, the image itself is drawn fine, BUT the dot in not in the right position.

UPDATE: As can be seen in the code below, I added console.log statements to print out the width and height of the original image. In the offending browsers these values are half of what they should be. I’m now trying to figure out why.

Code:

window.onload = function zoomIn() {
    var canvas = document.getElementById("area");
    var context = canvas.getContext("2d");
    var imageObj = new Image();
    var px = 1988;
    var py = 734;
    imageObj.src = "IMAGE URL GOES HERE";
    imageObj.onload = function() {
      canvas.width=640;
      canvas.height=480;
      if(px-canvas.width<0 || py-canvas.height<0){
          canvas.width=500;
          canvas.height=300;
      }

      console.log(imageObj.height);
      console.log(imageObj.width);

      context.drawImage(imageObj, px-canvas.width, py-canvas.height, canvas.width*2, canvas.height*2,0,0,canvas.width,canvas.height);


      context.beginPath();
      context.arc(canvas.width/2, canvas.height/2, 10, 0, 2 * Math.PI, false);
      context.fillStyle = "red";
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = "black";
      context.beginPath();
      context.font = "10pt Calibri";
      context.fillStyle = "black"
      context.textAlign = "center";
      context.fillText("You Are Here", canvas.width/2, canvas.height/2+20);
      context.stroke();
    };
  document.form1.button2.style.visibility="hidden"
  document.form1.button1.style.visibility="visible";
};

function zoomOut(){
   var canvas = document.getElementById("area");
   var context = canvas.getContext("2d");
   var imageObj = new Image();
   var px = 1988;
   var py = 734;
   imageObj.src = "IMAGE URL GOES HERE";
   imageObj.onload = function(){
      canvas.width=imageObj.width
      canvas.height=imageObj.height
      context.drawImage(imageObj,0,0);

      context.arc(px, py, 20, 0, 2 * Math.PI, false);
      context.fillStyle = "red";
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = "black";

      context.beginPath();
      context.rect(0, 0, canvas.width, canvas.height);
      context.font = "15pt Calibri";
      context.fillStyle = "black";
      context.textAlign = "center";

      context.fillText("You Are Here",px,py+25);
      context.stroke();
   };
   document.form1.button1.style.visibility="hidden"
   document.form1.button2.style.visibility="visible";
}
  • 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-06-07T03:43:30+00:00Added an answer on June 7, 2026 at 3:43 am

    If you have read my entire post (excluding the code) you will know that I eventually discovered that the dimensions of the original image on the iPhone we’re half of what they were in the other browsers.

    This is caused by a limit Apple has placed on the size of an image that can be downloaded, which is 3 Megapixels. My image was larger than that. But the Javascript made references to parts of the image that (on iOS) we’re beyond its bounds.

    Source: Apple Documentation: Know iOS Resource Limits

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

Sidebar

Related Questions

I'm attempting to run an IronRuby script from C#: var runtime = IronRuby.Ruby.CreateRuntime(); runtime.ExecuteFile(ruby/foo.rb);
I'm attempting to create a page that displays and refreshes an image from a
I am attempting to run a command as root from a php page, is
I'm attempting to run a file that calls multiple files, but I'm getting some
I am attempting to run some unit tests in python from what I believe
I'm attempting to complete and exercise from the JavaScript Bible, and am having trouble
Attempting to run a MIB based SNMP script and I running into an issue.
I am attempting to run a JUnit Test from a Java Class with: JUnitCore
I am attempting to parse javascript (using javascript), and I've run into a problem
Attempting to run adt from an SSH session results in: Exception in thread main

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.