Tim Dietrich

Custom Software Developer

Home Services Portfolio Blog About Contact Newsletter

FileMaker WebDirect: Alternatives to the "Open URL" Script Step

While FileMaker WebDirect supports the "Open URL" script step, when it is used, it always opens the URL in a new window. That's not always the desired effect.

Using a Web Viewer and some basic Javascript, it is possible to simulate the Open URL script step and open URLs in the same window, or in a new tab. Here's how...

Redirecting In the Same Tab

If you want to redirect the WebDirect user to an entirely new location, and do so in the current tab, then you can use the "top.location.href" method. With this approach, "top" forces a redirect of the tab itself - not just of the Web Viewer.

Here is an example of what the Javascript would look like.

<!DOCTYPE html>
<html>
<head>
<title>
WebDirect Redirect</title>
</head>
<body>
<script>
top.location.href = 'http://filemaker.com';
</script>
</body>
</html>

To use that code, you would create a layout and place a Web Viewer layout object on it. Setup the Web Viewer to use a Custom Web Address, and then configure it to use a Data URL (with "data:text/html," followed by the code above). Then, simply navigate the WebDirect user to the layout. They'll be redirected to the new URL.

However, note that their WebDirect session will remain open on the server, until the session times out. Also, if the user tries to go back to the WebDirect page, they will be required to reauthenticate. So use this approach with care.

Opening A URL In A New Tab

Another option is to navigate the WebDirect user to a new URL in a new tab. With this approach, the user's original WebDirect tab remains open and unaffected. Here's what that Javascript would look like.

<!DOCTYPE html>
<html>
<head>
<title>
WebDirect New Tab</title>
</head>
<body>
<script>
var newWindow = window.open('http://filemaker.com/');
</script>
</body>
</html>

In this example, we're opening a new tab using "window.open," and we've specified the URL for the new tab. The original WebDirect tab remains open. And again, to use this approach, you would follow the same steps that I listed above.