Hello forum,
I’m trying to open a project webpage in a new window by using the following two approaches that I learned from the forum:
-
'ExecuteJavaScript(“window.open(”“http://127.0.0.1:8080/?page=mywebpage”“);”)
-
‘ExecuteJavaScript("window.open(’" + “http://127.0.0.1:8080” + “/mywebpage”, ‘_blank’);")
However, both options direct to the main page. Can anyone shed me some light?
First, don’t use ExecuteJavaScript for this. Use WebSession.GotoURL.
Session.GotoURL( "https://127.0.0.1/?page=somePage", True )
Second, you need some way of determining where to send the user when the request comes in. This is typically done in Session.Opening. You’ll parse the path or querystring and react accordingly by calling whatever target page you want to show the user. So something like:
Sub Opening() Handles Opening
if Session.URLParameterExists( "page" ) then
select case Session.URLParameter( "page" )
case "somePage"
somePage.Show
Return
end select
end if
homePage.Show
End Sub
2 Likes
Here’s an example project:
web_redirect.xojo_binary_project.zip (9.5 KB)
1 Like
This is extremely helpful! I tried to implement your code in the previous post but I was confused with “somePage” with my project webpage. Now I understand what you mean. Thank you so much!
1 Like