Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: mimeTypes

  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mimeTypes

    Hi, It seems that it's something wrong with the mimeTypes, when I write:


    alert(navigator.mimeTypes.length)

    it gives me zero! I have almost everything in my browser, I can see the flash files, movies, sounds and almost everything! why doesn't it work?

    something else, let's say that I wana see if my clients have the flash player installed on their browsers, and based on that I show some stuff, the following should work:

    <script>
    // Can we display Shockwave movies?
    mimetype = navigator.mimeTypes["application/x-director"]
    if (mimetype) {
    // Yes, so can we display with a plug-in?
    plugin = mimetype.enabledPlugin
    if (plugin)
    // Yes, so show the data in-line
    document.writeln("Here\'s a movie: <EMBED SRC=mymovie.dir HEIGHT=100 WIDTH=100>")
    else
    // No, so provide a link to the data
    document.writeln("<A HREF='mymovie.dir'>Click here</A> to see a movie.")
    } else {
    // No, so tell them so
    document.writeln("Sorry, can't show you this cool movie.")
    }
    </script>


    but as I said, it shows my mimeTypes.length as zero! is it normal? I tried that on another comp too, but it's the same!

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Only Netscape browsers providing a meaningful mimeTypes array - it is always empty in IE and is essentially useless.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Someone else gave me this snippet ( he/she was a moderator too!), it's perfectly working, at least it shows "myFlash.swf", I dunno if it could find out if I don't have flash installed on my comp and it could show "myImage.gif" too!
    Here's the program:


    <script type="text/javascript">
    <!--
    plgIn = "Shockwave Flash";
    ok = false;
    document.returnValue = false;

    with (navigator)
    {
    if (document.all && appVersion.indexOf('Mac')==-1)
    document.write('<scrip'+'t language="VBScript">\nOn error resume next\n' + 'dir = (IsObject(CreateObject("SWCtl.SWCtl.1")) Or IsObject(CreateObject("Macromedia.ActiveShockwave.1")))\n' + 'flash = NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash"))\n<\/scrip'+'t>');

    if (!document.all)
    ok = (plugins && plugins[plgIn]);
    else
    if (appVersion.indexOf('3.1') == -1)
    {
    if (plgIn.indexOf("Flash")!=-1 && window.flash != null)
    ok = window.flash;
    else if (plgIn.indexOf("Director")!=-1 && window.dir != null)
    ok = window.dir;
    }
    else
    ok = autoGo;

    if (ok)
    document.write('<embed src="myFlash.swf" type="application/x-shockwave-flash" loop="false" menu="false" quality="autohigh" pluginspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
    else
    document.write('<img src="myImage.gif" type="image/gif" alt="My Image">');
    }
    //-->


  •  

    Posting Permissions

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