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)


#3

(1) What I would like to achieve is the following: being able to go back in a clickpad to a specific screen, from which the path was originally taken. Moreover, the path can also be started from different origins.
Therefore, when I leave the origin, I want to save the page and use it again in a link later.
I tried this by putting the page name in a global variable on exit:
Set Variable Value OriginPage to “[[PageName]]”, or more precise:
Set Variable Value OriginPage to “[[PageName.toLowerCase().replace(” “, “_”)]].html”
… and then use it again later in a link like [[OriginPage]]
… as already clearly explained above by mbc66:

This has worked well for me in the past, but unfortunately this method doesn’t seem to work anymore (not even in Axure file from the attachment of mbc66 - see above), and it seems that Axure generates extra code in the axshare urls which is necessary (without this code urls don’t work) but which you can’t just make yourself. Example: https://q8fyq5.axshare.com/#id=oz3n2m&p=page_2.
The urls https://q8fyq5.axshare.com/p=page_2 or
https://q8fyq5.axshare.com/page_2
… however lead to “Hmmm… This page doesn’t exist.”

Does anyone have an idea how I can achieve with Axure (9) what I describe above, and what worked before?

(2) Then I also have a specific question about the JavaScript to replace spaces with underscores:
toLowerCase().replace(" “, “")
… I would also like to replace dots with underscores, because I use dots in the page names and I see that Axure changes those in the urls to underscores as well.
Can I simply extend the script as follows?
toLowerCase().replace(" ", "
”).replace(”.", “_”)

Thanks in advance!

cheers,

Igor