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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:01:56+00:00 2026-06-15T00:01:56+00:00

Hey i have the following statechange event set on the window : History.Adapter.bind(window,’statechange’,function(e){ console.log(statechange

  • 0

Hey i have the following statechange event set on the window :

History.Adapter.bind(window,'statechange',function(e){ 
 console.log("statechange event occured ");
 //more code
    var newDoc = document.open();
    newDoc.write(file);
    newDoc.close();
});

i’m using history.js but that doesn’t matter in this case as it binds the statechange regulary, i am getting the value of file like should be and works fine.

Now i have this code (and other code) inside an external js file,
inside the file i’m iterating through all a tags and apply the following click event :

    $(element).on("click",function(e){
    e.preventDefault();
    //more code

    History.pushState({file : file},title, fullHref);


});

Now when i click the document is getting changed as expected but when trying to use back/forward buttons statechange event does not fire.

I should mention that this js is included in the files im loading as well.

So my initial thought was that as the document changes but the window doesn’t, the event remains. which is not true as it applies the statechange event multipile times. So i tried applying the event once using cookie but that still does the same thing.

Now if instead of changing the document i simply apply it with jQuerys .html() the statechange event gets fired as exepected so i guess it’s related to the document.

Why could this happen? I believe if i understood more about what happens to window events when changing documents i could solve this problem.

Tries :

  • I have now also tried binding to the popstate event via regular History API, still same results give or take. pushState doesn’t fire popstate but back button does but without state.
  • I have come to the conclusion that i shouldn’t be using history.js as i susspect the problem came from there so i “solved” my problems with popstate which still causing problems as document.open seems to be firing popstate. still looking for more information
  • I’ve tried using on, same result

Information :

  • the fact this example us using History is because of history.js, if i use regular history API still same problems.

I have read in mdn that :

{{ gecko_minversion_note(“1.9.2”, “Starting with Gecko 1.9.2, document.open() uses the

principal of the document whose URI it uses, instead of fetching the
principal off the stack. As a result, you can no longer call
document.write() into an untrusted document from chrome, even using
wrappedJSObject.”) }}

Which im not sure but i think could be realted to this problem

  • 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-15T00:01:57+00:00Added an answer on June 15, 2026 at 12:01 am

    Well, in the end i discovered that all though you only change document, window events gets deleted as they lay inside the document.

    I encoutred my problems with History.js i think because the fact that im changing documents break it at some point.

    What i did was use native HTML5 history API and rebinded the popstate event in the new document.

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

Sidebar

Related Questions

Hey - I have the following method on my UITableView controller public void RemoveEventFromList(Event
Hey, I have the following function: function getPosition() { var cLeft = $('#element').position().left; var
Hey guys. I have the following models: Category Event Lock Item Site User Events
Hey dudes, I have the following function: $.fn.slideOut = function(speed,dir) { this.animate({ dir: '-1000px'
Hey all i have the following js code to validate a textbox: function submitContactUs()
Hey community I have the following ServerSocket which should listen to port 53000 and
Hey Guys, i have created the following Menu Structure: <div id=menu> <ul> <li><a href=#>Main
Hey all. I have a question on how to implement the following with Django.
Hey all, basically i have an empty AS3 fla file with just the following
Hey I have following code like this public object RetrieveItemRun(int item) { if (dictionary.ContainsKey(item))

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.