Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[SugarCube v0.9.9] Strange bug with state.display on WebKit browsers (iOS 7)

I have a form embedded as an iFrame. It seems to work fine on desktop platforms, but on Mobile Safari and on the latest iOS Chrome (iOS 7.1 and perhaps others), once the form has been submitted, calls to state.display()--including those that result from template-generated link-internal links--uniformly result in an error. That error is:

[quote]Apologies! [Standard boilerplate]...
Error: TypeError: 'null' is not an object (evaluating 'History.getWindowState().sidx')

The problem does not occur in desktop Chrome or in Firefox.

The issue does not occur if the iFrame is merely present; it's only after submitting the form that things break. My best guess is that the history is somehow getting polluted by navigation in the iFrame. Looking at the Sugarcube source for History.getWindowState, it seems very likely that window.history has been...compromised somehow. I've done some googling but haven't come across any bug reports for this.

The <form> in the iFrame is in a simple web page hosted on my domain. Clicking Submit on the form sends the data to JotForm.com, which then forwards to a separate "thank you" page on my domain. Finally, this page calls a script in the main window like so: window.top.formSubmit(); (The formSubmit script merely sets a Twine variable so that the form is not shown to the viewer again on a second visit to the passage.)

Any tips on how I might work around this would be very welcome!

Comments

  • Code for formSubmit?
  • I merely described it above since it almost certainly isn't a factor. At the time I posted, it was:
    window.formSubmit = function () {
    state.active.variables.registration = true;
    //storage.setItem("registration", true);
    }
    Now the commented line replaces the variable setting code.
  • Hmm.  The reason I wanted to see it is because the only thing I can think of is a scoping issue.  Basically, what's probably happening is that since you're calling around between the main window and the iframe at some point SugarCube code is being called within the scope of the iframe, hence the lossage.

    Let me look into it.  If you could PM me a test setup or, at least, a better description of the parts involved, that would helpful.
Sign In or Register to comment.