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).

Example



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();
}

// 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.");
    return;
  }
		
  // Check that video has been recorded.
  if( _Guid == "" )
  {
    alert("Error: GUID is empty.");
    return;
  }
	
  // Set the redirection URL.
  form.action = url.value;
	
  // Set the guid as hidden parameter.
  form.guid.value = _Guid;
	
  // Redirect.
  form.submit();
}

// -->
</script>
<object id="nimbb" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240" codebase= "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="https://player.nimbb.com/nimbb.swf?mode=record&simplepage=1&key=XXXXXXXXXX&lang=en" />
<param name="allowScriptAccess" value="always" />
<embed name="nimbb" src="https://player.nimbb.com/nimbb.swf?mode=record&simplepage=1&key=XXXXXXXXXX&lang=en" width="320" height="240" allowScriptAccess="always" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash">
</embed>
</object>

<br><br>
Redirection URL: <br>
<input id="urlTextBox" type="text" name="name" style="width:320px;" value="https://www.nimbb.com/Doc/Tutorials/Thanks.aspx">

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

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.