Callback page redirect

MiServer is Dyalog's APL-based web development framework
Post Reply
Davin Church
Posts: 2
Joined: Sun Jul 25, 2021 2:56 am

Callback page redirect

Post by Davin Church »

Pardon my newbie question, but I want an APL callback fn to redirect their browser to a new page, just like it was an <a> link that was clicked on. However it needs to be done under program control because the URL is being dynamically generated.

Is there a built-in way to do this?
Davin
User avatar
Brian|Dyalog
Posts: 120
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Re: Callback page redirect

Post by Brian|Dyalog »

Hi Davin,

To redirect to a page from a callback function, just return some JavaScript to set location.href to the new URL.

Code: Select all

 :Class index : MiPage                               
                                                     
     ∇ Compose                                       
       :Access public                                
       (Add _.Button'Click Me').On'click' 'callback' 
     ∇                                               
                                                     
     ∇ r←callback                                    
       :Access public                                
       r←Execute'location.href="https://dyalog.com"' 
     ∇                                               
                                                     
 :EndClass                                           
I hope this helps!
/Brian
Davin Church
Posts: 2
Joined: Sun Jul 25, 2021 2:56 am

Re: Callback page redirect

Post by Davin Church »

Excellent! Thanks, Brian. My JS is very weak and wasn't even sure how to approach that.
Davin
Post Reply