How to load and unload stories dynamically in Quixe?

I have a project where I need to load multiple stories (not at the same time) in Quixe via JavaScript, without reloading the page.

I have the default Quixe template (play.html) with the following line removed:

<script src="stories/glulxercise.ulx.js" type="text/javascript"></script>

To load a story, I empty the #windowport element and use

GiLoad.load_run(null, data, "base64");

where data is a string representing the story Glulx file.

It work fine the first time, but when I try to load another story, Quixe crashes with the message “Quixe was inited twice!”.

Is there a way to “quit” Quixe before loading another story?

I guess Zarf will be the one answering, so thanks in advance, Zarf!

Um, I don’t think this can be done without a bunch of Quixe engineering. There’s no code to clear out the data structures. Even if you took out that double-init check, re-running quixe_init() has never been tested and I don’t make any promises about it.

You could maybe store some data in browser local storage, reload the page, and pull the data back out.

I ended up having a HTML file per story, and using iframes that I can show and hide when needed.

Not what I would have prefered, but it may finally be better and it seems to work, so I think all is OK.

Thanks anyway!