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 993735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:28:14+00:00 2026-05-16T06:28:14+00:00

I’m using Google closure to create a simple interactive graphic in HTML/JS to be

  • 0

I’m using Google closure to create a simple interactive graphic in HTML/JS to be viewed on iPad Safari.

The code sample below shows expected behavior on Safari Mac and all other major browsers (a circle appears that when clicked generates a console message), but not Safari iPad. No event handler is registered with the circle. Instead, an error is thrown.

goog.require('goog.graphics'); 
goog.require('goog.events.EventType'); 
goog.require('goog.graphics.Stroke'); 
goog.require('goog.graphics.SolidFill'); 

var showCircle = function() { 
  var graphics = goog.graphics.createGraphics(400, 400); 
  var stroke = new goog.graphics.Stroke(1, 'black'); 
  var fill = new goog.graphics.SolidFill('#00ff00', 0.5); 
  var circle = graphics.drawEllipse(100, 100, 30, 30, stroke, fill); 
  var element = goog.dom.getElement('demo'); 
  graphics.render(element); 
  console.info(circle.getElement()); 
  goog.events.listen(circle, goog.events.EventType.MOUSEDOWN, function(e) { 
    console.info('mousedown'); 
  });
};

The error reads (thrown from base.js):

JavaScript Error on Line 804 … TypeError: Result of expression ‘obj’ [null] is not an object.

I think I’ve traced the problem to the lack of a DOM element for circle, and the fact that registering a listener on circle attempts to register a listener on circle.getElement(). When queried, circle.getElement() returns null, explaining the error. Note that the console output message prints null on iPad Safari, but:

<ellipse cx=​"100" cy=​ "100" rx=​"30" ry=​"30" stroke=​"black" stroke-width=​"1" fill=​ "#00ff00" fill-opacity=​"0.5">​

on Mac Safari.

On both Mac and iPad Safari, the circle is drawn the same. The only difference is the error. Using ‘touchstart’ as the event name instead of goog.events.EventType.MOUSEDOWN makes no difference.

I want to register an event listener with circle without an
error being generated on iPad. How can I do this?

  • 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-16T06:28:15+00:00Added an answer on May 16, 2026 at 6:28 am

    I think I found the answer. For those who are interested…

    Using Firebug Light I noticed that the drawing element that was created was <canvas>. Seems totally obvious now, but goog.graphics.createGraphics creates a canvas tag by default for iPad. This explains why circle.getElement() returns null.

    We need SVG, which is supported by iPad. Closure can be tricked into providing SVG graphics with something like:

      var oldMobileSetting = goog.userAgent.MOBILE;
      goog.userAgent.MOBILE = false;
      var graphics = goog.graphics.createGraphics(400, 400);
      goog.userAgent.MOBILE = oldMobileSetting;
    

    Doing this, the demo works as expected. Alternatively, we could directly create SVG graphics if iPad environment is known by directly instantiating:

    var graphics = new goog.graphics.SvgGraphics(400, 400);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.