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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:21:16+00:00 2026-06-09T18:21:16+00:00

I have a problem with my Google closure code. I’m trying to implement an

  • 0

I have a problem with my Google closure code.
I’m trying to implement an App using HTML5 History feature.

But unfortunately this is not working as I’m getting an ‘CANNOT READ PROPERTY ‘HTML5HISTORY’ OF UNDEFINED’ on Chrome and ‘goog.history is undefined’on Firefox.

Basically the “var h” is never created with the History instance, as I’m getting the error from the “try/catch” loop, and the error.message displayed.

I really don’t know what’s the problem…

Thanks Guys

goog.require('goog.events');
goog.require('goog.events.EventTarget');
goog.require('goog.history.EventType');
goog.require('goog.history.Html5History');
goog.require('goog.Uri');

var h;

try {

 h = new goog.history.Html5History();

} catch (e) {

     document.write(e.message);
}

if (h) {

    var cur = 'kittens';

    goog.events.listen(h, goog.history.EventType.NAVIGATE, function(e) {
        var token = e.token || 'kittens';

        var next = document.getElementById(token);

        if (next) {

            document.getElementById(cur).className = 'section';
            next.className = 'section active';
            cur = token;
        }
    });

    h.setUseFragment(false);
    h.setPathPrefix(new goog.Uri(document.location.href).getPath() + '/');
    h.setEnabled(true);

    goog.events.listen(document.getElementById('links'), 'click', function(e) {

        if (e.target.tagName == 'A') {

            h.setToken(e.target.getAttribute('token'), e.target.title);
            e.preventDefault();
        }
    });
 }
  • 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-09T18:21:17+00:00Added an answer on June 9, 2026 at 6:21 pm

    Include all imports (goog.require() calls) in a separate JavaScript file or tag before this your script including.

    Documentation says:

    Note: Do not put your goog.require() statements in the same script tag
    as the entry point to code that uses the goog.required functions or
    classes. A goog.require() call adds code to the document after the
    script tag containing the call. For example, this code works:

    <script src="closure-library/closure/goog/base.js"></script>
    <script>
      goog.require('goog.dom');
    </script>
    <script>
      var newHeader = goog.dom.createDom('h1');
    </script>
    

    In contrast, the following code produces an error:

    <script src="closure-library/closure/goog/base.js"></script>
    <script>
      // DON'T DO THIS.
      goog.require('goog.dom');
      var newHeader = goog.dom.createDom('h1');
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with javascript code. I am using google maps and I am
I'm using the reCAPTCHA service from Google but I have problem in IE6 where
I have a little problem about Google Maps. I'm using Geocoding (xml) for getting
I have problem with items order in legend, when I using Google Chrome browser
I have a problem and search for a solution on Google but can't find
I have a problem with the using the Ace editor on my Python-based Google
I have a big problem with Google Chrome and its memory. My app is
I have a problem with Google Cloud Print. It works perfectly, but it's a
I have a problem with Google suggest API when using Chinese locale. I am
I have a problem about google map. I did an app about include google

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.