Get previous page name

i am using a function to get the previous page name but it is not working can you show me some example to get previous page name
this shows undefined

Please describe what you are really trying to achieve at a higher level, because “get the previous page name” (a) is going to be extremely problematic, especially in production code, (b) isn’t always going to be a meaningful concept, and © would seem to indicate overly tight coupling between pages, which is a hallmark of bad design.

i want to check if i redirect from a specific page only then i will open a model else not . i have used parameters for now but i was looking for something more meaningful

Can you pop the modal from the referring page instead? That seems cleaner.