How to get gotoWebPage() script function to work in Windows
by Mark Harmon · 05/19/2003 (11:25 am) · 1 comments
Whenever I clicked on a web link, in my game, my browser would open up and try to connect to "%1". That is not the url I put as the argument to the gotoWebPage() function.
The gotoWebPage() console function calls Platform::openWebBrowser() to take care of the dirty work. The Windows implementation of this method looks up some registry keys to find the appropriate browser program to run. The registry key holds a string value that is the path and command line arguments needed to open to a specific url. The problem is that in the value there is a "%1" that is meant to be replaced by a string representing the url to open. This needs to be stripped before appending the url to the string.
To fix it open platformWin32/winWindow.cc and find the Platform::openWebBrowser method.
Just before these two lines:
char buf[1024];
dSprintf( buf, sizeof( buf ), "%s %s", (const char*) sWebKey, webAddress );
Add these two lines:
char *pToken = dStrstr((const char*)sWebKey, "\"%1\"");
if (pToken) *pToken = 0;
This works whether the %1 is in the string or not.
The gotoWebPage() console function calls Platform::openWebBrowser() to take care of the dirty work. The Windows implementation of this method looks up some registry keys to find the appropriate browser program to run. The registry key holds a string value that is the path and command line arguments needed to open to a specific url. The problem is that in the value there is a "%1" that is meant to be replaced by a string representing the url to open. This needs to be stripped before appending the url to the string.
To fix it open platformWin32/winWindow.cc and find the Platform::openWebBrowser method.
Just before these two lines:
char buf[1024];
dSprintf( buf, sizeof( buf ), "%s %s", (const char*) sWebKey, webAddress );
Add these two lines:
char *pToken = dStrstr((const char*)sWebKey, "\"%1\"");
if (pToken) *pToken = 0;
This works whether the %1 is in the string or not.
About the author

Torque Owner Tim Gift