Store page in variable and navigate back to the page later


#1

Hi,

is it possible to store the URL of a page in a variable that I can later on invoke to jump back to that page?
I only found [[PageName]] so far, but that only provides the name of the page of course.


#2

Yes, you can store any text in a global variable, including a URL. You can construct “local” URLs (direct links to pages in the prototype) from the internal variable, [[PageName]] . If you inspect the page’s URL in the browser, or better yet, look at the “shareable URL” from the Get Links button in the left pane of the Axure prototype in a browser, you will see that a page URL is all lowercase, with spaces replaced by underscores. So, you can use this basic formula to create a page’s URL:
[[PageName.toLowerCase().replace(" ", "_")]].html

There is (at least) one caveat though. When you jump to a direct URL like this, the browser treats it as a new instance/session, so all global variables are reset. The navigation history is reset also, so the browser’s Back and Forward buttons may not work as expected.

I’ve demonstrated this in the example below. If you navigate to any of the child pages, the global variable, OnLoadVariable, will get set to the page’s URL. An additional global variable, PageLoads, will increment with every page load/reload. If you then navigate back to Home, you will see a link to the last visited page. If you click that (direct URL) link, the page will load, but PageLoads will be reset to 1.

So, if you need to track other data across pages, the only way I’ve found to get around this is to store [[PageName]] in a global variable, and then a long series of conditions for an OnClick event, e.g., “If [[PageName]] contains “1” Open “Page 1” in Current Window, Else If [[PageName]] contains “2” Open “Page 2” in Current Window” etc.

page url.rp (151.5 KB)