Html code for Webcam
Results 1 to 8 of 8

Thread: Html code for Webcam

  1. #1
    Registered User
    Join Date
    Dec 2000
    Location
    Knoxville, TN
    Posts
    176

    Html code for Webcam

    I have an Axis 2100 Network cam and I have a webapge that will grab the streaming video from the cam. Only one problem. For Internet Explorer it uses ActiveX and for the others it should use Java Script to show the video.
    Works fine in all browsers except Opera. Opera's default setting in Browser Identification is IE 6.0. So when someone with Opera goes to the site it tries to load Active-X instead of Java.

    Is there a way to just make all browsers use Java? I tried many different things and it keeps giving me errors. I figured someone out here would be able to help me. Thanks in advance

    Here is the script

    <!-- Cut from here to the end of image display comment -->
    <!-- Note: If you do not see a JavaScript below in the view source window you must -->
    <!-- first save the html file from your browser, then open the saved -->
    <!-- file in a text editor, for instance Notepad.-->

    <p>
    <SCRIPT LANGUAGE="JavaScript">
    // Set the BaseURL to the url of your camera
    // Example: var BaseURL = "http://172.21.1.122/";

    var BaseURL = "";

    // The two following lines are for AXIS 2400:

    var Camera = ""; // If you use an AXIS 2400, comment away this line by inserting "//"
    // var Camera = "n"; // Change n to the Video source used in the AXIS 2400 and remove "//"

    // Go to the camera used and remove the "//" in front of the ImageResolution to be used.
    // Note that only one can be enabled.

    // AXIS 2100
    // var ImageResolution = "320x240";var DisplayWidth = "320";var DisplayHeight = "240";
    // var ImageResolution = "640x480";var DisplayWidth = "640";var DisplayHeight = "480";

    // AXIS 2120/2400/2401/2420 PAL
    // var ImageResolution = "352x288";var DisplayWidth = "352";var DisplayHeight = "288";
    // var ImageResolution = "704x576";var DisplayWidth = "704";var DisplayHeight = "576";

    // AXIS 2120/2400/2401/2420 NTSC
    // var ImageResolution = "352x240";var DisplayWidth = "352";var DisplayHeight = "240";
    // var ImageResolution = "704x480";var DisplayWidth = "704";var DisplayHeight = "480";


    // No changes required below this point
    var File = "axis-cgi/mjpg/video.cgi?resolution=" + ImageResolution;
    if (Camera != "") {File += "&camera=" + Camera;}
    var output = "";
    if ((navigator.appName == "Microsoft Internet Explorer")&&(navigator.platform != "MacPPC")&&(navigator.platform != "Mac68k"))
    {
    // If Internet Explorer for Windows then use ActiveX
    output = "<OBJECT ID=\"CamImage\" WIDTH="
    output += DisplayWidth;
    output += " HEIGHT=";
    output += DisplayHeight;
    output += " CLASSID=CLSID:917623D1-D8E5-11D2-BE8B-00104B06BDE3 ";
    output += "CODEBASE=\"";
    output += BaseURL;
    output += "activex/AxisCamControl.cab#Version=1,0,2,15\">";
    output += "<PARAM NAME=\"URL\" VALUE=\"";
    output += BaseURL;
    output += File;
    output += "\"> <BR><B>Axis ActiveX Camera Control</B><BR>";
    output += "The AXIS ActiveX Camera Control, which enables you ";
    output += "to view live image streams in Microsoft Internet";
    output += " Explorer, could not be registered on your computer.";
    output += "<BR></OBJECT>";
    }
    else
    {
    // If not IE for Windows use the browser itself to display
    output = "<IMG SRC=\"";
    output += BaseURL;
    output += File;
    output += "&dummy=garb\" HEIGHT=\"";
    // The above dummy cgi-parameter helps some versions of NS
    output += DisplayHeight;
    output += "\" WIDTH=\"";
    output += DisplayWidth;
    output += "\" ALT=\"Moving Image Stream\">";
    }
    document.write(output);
    </script>
    <!-- End of image display part -->
    Its all fun and games until someone loses an eye, then its just fun in the dark.

    3 out of 2 people can't count.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    110
    At first glance.... you're using navigator.appName, see what happens if you try navigator.userAgent

  3. #3
    Registered User
    Join Date
    Dec 2000
    Location
    Knoxville, TN
    Posts
    176
    Quote Originally Posted by darkhorse
    At first glance.... you're using navigator.appName, see what happens if you try navigator.userAgent
    Thanks for the reply, but if I change that it stops working in IE.
    Its all fun and games until someone loses an eye, then its just fun in the dark.

    3 out of 2 people can't count.

  4. #4
    Registered User CeeBee's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    2,494
    Get rid of the condition check from "if ((navigator.appName.." to "else", this should force all browsers to use the non-ie script.
    Protected by Glock. Don't mess with me!

  5. #5
    Registered User
    Join Date
    Dec 2000
    Location
    Knoxville, TN
    Posts
    176
    Quote Originally Posted by CeeBee
    Get rid of the condition check from "if ((navigator.appName.." to "else", this should force all browsers to use the non-ie script.
    Okay I took that out (by the way thanks for the reply)

    and now it looks like this after all the camera options

    // No changes required below this point
    var File = "axis-cgi/mjpg/video.cgi?resolution=" + ImageResolution;
    if (Camera != "") {File += "&camera=" + Camera;}
    var output = "";

    // If not IE for Windows use the browser itself to display
    output = "<IMG SRC=\"";
    output += BaseURL;
    output += File;
    output += "&dummy=garb\" HEIGHT=\"";
    // The above dummy cgi-parameter helps some versions of NS
    output += DisplayHeight;
    output += "\" WIDTH=\"";
    output += DisplayWidth;
    output += "\" ALT=\"Moving Image Stream\">";
    }
    document.write(output);
    </script>
    <!-- End of image display part -->
    </p>
    <p><a href="#" onclick="javascript:window.open('streamwebcamremot e.htm', 'none', 'width=340,height=335');">Click
    here to open a remote window</a> </p>
    </body>
    </html>

    But now it gives me a javascript error.
    Its all fun and games until someone loses an eye, then its just fun in the dark.

    3 out of 2 people can't count.

  6. #6
    Registered User
    Join Date
    Dec 2003
    Posts
    38
    Quote Originally Posted by Packrat
    Okay I took that out (by the way thanks for the reply)

    and now it looks like this after all the camera options

    <sniped and moved code>

    But now it gives me a javascript error.
    Looking over your code, looks likes you cut the coditional statement if(stuff=stuff){}else{

    and left the trailing } behind at the end. I commented it out below, try that or just remove it, should fix the script error.

    Code:
    // No changes required below this point
    var File = "axis-cgi/mjpg/video.cgi?resolution=" + ImageResolution;
    if (Camera != "") {File += "&camera=" + Camera;}
    var output = "";
    
    // If not IE for Windows use the browser itself to display
    output = "<IMG SRC=\"";
    output += BaseURL;
    output += File;
    output += "&dummy=garb\" HEIGHT=\"";
    // The above dummy cgi-parameter helps some versions of NS
    output += DisplayHeight;
    output += "\" WIDTH=\"";
    output += DisplayWidth;
    output += "\" ALT=\"Moving Image Stream\">";
    //}
    document.write(output);
    </script>
      <!-- End of image display part -->
    </p>
    <p><a href="#" onclick="javascript:window.open('streamwebcamremote.htm', 'none', 'width=340,height=335');">Click 
      here to open a remote window</a> </p>
    </body>
    </html>

  7. #7
    Registered User
    Join Date
    Dec 2000
    Location
    Knoxville, TN
    Posts
    176
    Quote Originally Posted by noone
    Looking over your code, looks likes you cut the coditional statement if(stuff=stuff){}else{

    and left the trailing } behind at the end. I commented it out below, try that or just remove it, should fix the script error.

    Code:
    // No changes required below this point
    var File = "axis-cgi/mjpg/video.cgi?resolution=" + ImageResolution;
    if (Camera != "") {File += "&camera=" + Camera;}
    var output = "";
    
    // If not IE for Windows use the browser itself to display
    output = "<IMG SRC=\"";
    output += BaseURL;
    output += File;
    output += "&dummy=garb\" HEIGHT=\"";
    // The above dummy cgi-parameter helps some versions of NS
    output += DisplayHeight;
    output += "\" WIDTH=\"";
    output += DisplayWidth;
    output += "\" ALT=\"Moving Image Stream\">";
    //}
    document.write(output);
    </script>
      <!-- End of image display part -->
    </p>
    <p><a href="#" onclick="javascript:window.open('streamwebcamremote.htm', 'none', 'width=340,height=335');">Click 
      here to open a remote window</a> </p>
    </body>
    </html>
    Thanks for the help,
    But it now will not work in IE....
    I also did some more testing. If I set Opera to not identify itself as IE (which is what it is set as on install) It runs terrible using Java. Think I will just give up on Opera and put a footnote for them to install IE, NS, or Mozilla.

    Thanks again.
    Its all fun and games until someone loses an eye, then its just fun in the dark.

    3 out of 2 people can't count.

  8. #8
    Registered User
    Join Date
    Mar 2005
    Posts
    1
    hello...
    is it possible to have live view of this webcam, without keep manualy refreshing.

    "http://webcam-rade.ville-ge.ch/axis-cgi/jpg/image.cgi?camera=..."

    this one looks the way but e keep getting the download messege instand of the video at the browser

    "http://webcam-rade.ville-ge.ch/axis-cgi/mjpg/video.cgi?resolution=320x240"

    thanks

Similar Threads

  1. SCO...does it have a chance?
    By Dark Millennium in forum Linux
    Replies: 8
    Last Post: August 26th, 2003, 06:37 PM
  2. Saving HTML emails from Outlook to a Word Doc.
    By Ya_know in forum Tech-To-Tech
    Replies: 7
    Last Post: April 10th, 2003, 09:57 AM
  3. found code red. any ideas?
    By melon in forum Spyware & Antivirus - Security
    Replies: 7
    Last Post: September 16th, 2001, 11:39 AM
  4. disable HTML on web forums
    By JungleMan1 in forum Comments and Suggestions
    Replies: 15
    Last Post: August 4th, 2001, 04:26 PM
  5. IE 5.5 - refresh sometimes shows the html code
    By red4 in forum Windows 95/98/98SE/ME
    Replies: 1
    Last Post: July 16th, 2001, 06:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •