Have you reviewed Using_Javascript?
Hi esmi, Yes, it seems to indicate that for one off uses, writing the code between <script> and </script> using the text editor should work, however it doesn’t. The code is actually fairly straightforward too :
<SCRIPT LANGUAGE="JavaScript">
// Set the BaseURL to the URL of your camera
var BaseURL = "http://ymaes.axiscam.net/";
// DisplayWidth & DisplayHeight specifies the displayed width & height of the image.
// You may change these numbers, the effect will be a stretched or a shrunk image
var DisplayWidth = "320";
var DisplayHeight = "240";
// This is the path to the image generating file inside the camera itself
var File = "axis-cgi/mjpg/video.cgi?resolution=320x240";
// No changes required below this point
var output = "";
if ((navigator.appName == "Microsoft Internet Explorer") &&
(navigator.platform != "MacPPC") && (navigator.platform != "Mac68k"))
{
// If Internet Explorer under Windows then use ActiveX
output = '<OBJECT ID="Player" width='
output += DisplayWidth;
output += ' height=';
output += DisplayHeight;
output += ' CLASSID="CLSID:DE625294-70E6-45ED-B895-CFFA13AEB044" ';
output += 'CODEBASE="';
output += BaseURL;
output += 'activex/AMC.cab#version=4,1,4,0">';
output += '<PARAM NAME="MediaURL" VALUE="';
output += BaseURL;
output += File + '">';
output += '<param name="MediaType" value="mjpeg-unicast">';
output += '<param name="ShowStatusBar" value="0">';
output += '<param name="ShowToolbar" value="0">';
output += '<param name="AutoStart" value="1">';
output += '<param name="StretchToFit" value="1">';
output += '<B>Axis Media Control</B>';
output += 'The AXIS Media Control, which enables you ';
output += 'to view live image streams in Microsoft Internet';
output += ' Explorer, could not be registered on your computer.';
output += '</OBJECT>';
} else {
// If not IE for Windows use the browser itself to display
theDate = new Date();
output = '<IMG SRC="';
output += BaseURL;
output += File;
output += '&dummy=' + theDate.getTime().toString(10);
output += '" HEIGHT="';
output += DisplayHeight;
output += '" WIDTH="';
output += DisplayWidth;
output += '" ALT="Camera Image">';
}
document.write(output);
document.Player.ToolbarConfiguration = "play,+snapshot,+fullscreen"
// Remove the // below to use the code for Motion Detection.
// document.Player.UIMode = "MDConfig";
// document.Player.MotionConfigURL = "/axis-cgi/operator/param.cgi?ImageSource=0"
// document.Player.MotionDataURL = "/axis-cgi/motion/motiondata.cgi";
</SCRIPT>
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
However, when i go to the this page on the internet….i see nothing, no stream, its as if the script is being ignored.
Have you checked your browser’s console log for anything more informative?
https://developers.google.com/chrome-developer-tools/docs/console
You need to enqueue this script correctly.
When you look at the source code, is it being output as you’d expect?
Hi esmi,
What do you mean by enqueue the script correctly?
Andrew Nevins : When viewing the page, and using the console, two ‘errors’ appear :
Uncaught SyntaxError: Unexpected token < http://www.ymaescafe.co.uk/:143
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
Webbrewers : Yes, the source code output is as expected i.e. its the same in WP as it was in the basic index page i created to test the script.
Since you “moved” the code, are you sure the path to the file and permissions are correct?
var File = "axis-cgi/mjpg/video.cgi?resolution=320x240";
What do you mean by enqueue the script correctly?
Have a look at http://codex.ww.wp.xz.cn/Function_Reference/wp_enqueue_script