Redirect user after recording using JavaScript

In this example, we show how to redirect the user after recording a video by using JavaScript. This could allow you to do a more advanced redirection by submitting form data.

This example requires you to specify your developer key (see tutorial).


Redirection URL:

HTML code

<script language="JavaScript" type="text/javascript">

// Global variable to hold player's reference.
var _Nimbb;

// Global variable to hold the guid of the recorded video.
var _Guid = "";

// Event: Nimbb Player has been initialized and is ready.
function Nimbb_initCompleted(idPlayer)
  // Get a reference to the player since it was successfully created.
  _Nimbb = document[idPlayer];

// Event: the video was saved.
function Nimbb_videoSaved(idPlayer)
  // Keep the video guid.
  _Guid = _Nimbb.getGuid();
  // Redirect user.

// Redirect user to the URL.
// Also send the guid as parameter.
function redirect()
  var url = document.getElementById("urlTextBox");
  var form = document.redirectForm;
  // Make sure the URL is specified.
  if( url.value == "" )
    alert("Error: URL is empty.");
  // Check that video has been recorded.
  if( _Guid == "" )
    alert("Error: GUID is empty.");
  // Set the redirection URL.
  form.action = url.value;
  // Set the guid as hidden parameter.
  form.guid.value = _Guid;
  // Redirect.

// -->
<object id="nimbb" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240" codebase= "">
<param name="movie" value="" />
<param name="allowScriptAccess" value="always" />
<embed name="nimbb" src="" width="320" height="240" allowScriptAccess="always" pluginspage="" type="application/x-shockwave-flash">

Redirection URL: <br>
<input id="urlTextBox" type="text" name="name" style="width:320px;" value="">

<form name="redirectForm" method="POST">
<input name="guid" type="hidden" value="">

In this example, the input box urlTextBox allows you to test the redirection to another URL.

Also note the presence of the redirectionForm form. This form is submitted when the video is saved. In addition, a hidden field guid contains the guid of the video. In your page that receives the redirection, simply access the request object to read the guid sent.

View more tutorials.

SIGN UP NOW 7-day free trial

Check out our Developer guide to get started with Nimbb.