Testing for Flash capability on the server-side

后端 未结 6 950
独厮守ぢ
独厮守ぢ 2021-01-14 23:23

I\'m developing an ASP.NET website that will need to support non-flash users.

In case the user\'s browser doesn\'t support Flash, or they have Flash disabled, I\'d l

相关标签:
6条回答
  • 2021-01-14 23:52

    Given your requirement I'd better use a Flash detection script which will detect Flash capabilities on the client and will redirect the user to another page instead of downloading the SWF file. You can find many scripts on Kirupa or you can use the one that is generated in the Flash publish options dialog

    0 讨论(0)
  • 2021-01-14 23:53

    You should not be dealing with this on the server side. Most Flash detection/embedding scripts do this sort of behaviour by default. I highly recommend SWFObject.

    • Create a <div> with your image (or any html you want really) inside it
    • Give it an ID eg: <div id="flash">
    • Tell SWFObject to override that div block with a Flash player

    If they have disabled, they see the unchanged html. If they have javascript enabled but no Flash plugin, they see the html as well. Basically, they'll see the Flash only if they have javascript and the Flash plugin.

    That's about as good as it gets.

    0 讨论(0)
  • 2021-01-14 23:54

    You might try using some server var:

    'HTTP_ACCEPT' against 'application/x-shockwave-flash'

    Not sure about .NET but it works most of the time in php. This does not work in Safari but for what you're doing that should be fine. You'll be saving yourself some bandwidth 95% of the time. PHP example(not .NET but you get the idea):

    if (strstr($_SERVER['HTTP_ACCEPT'], 'application/x-shockwave-flash')){
        $hasFlash = true;
    }
    
    0 讨论(0)
  • 2021-01-14 23:55

    There certainly are some reasons that you want to detect flash on the server side. We need certain parts to be completely replaced or left out on a page if flash is not available. Its not as simple as displaying alternate content in the exact place where the flash was. We need to replace html structure further up. And we need to do that even if Javascript is not available. It is not really an option to let javascript rewrite the page IF Flash is available and we can't just redirect to another page.

    0 讨论(0)
  • 2021-01-15 00:14

    The client-side flash detection is probably the better way to go. However, do keep in mind that you may have users with JavaScript disabled, such as people using the NoScript plugin. You have three basic choices for dealing with this that I can see.

    1. Ignore it. Perhaps you feel not enough people will be in this situation to be worth worrying about.

    2. Check for it, and have an indicator come up asking the user to enable JS for a better experience on this site. This is usually done by having the notice render in the page, and having JS code to disable or hide the rendering of that element.

    3. Attempt to support reasonably good site operation without JavaScript. This would probably involve having the large image load by default, and stopping that load from happening before it starts. That could be tricky.

    0 讨论(0)
  • 2021-01-15 00:17

    Browsers don't seem to send

    application/x-shockwave-flash
    

    in the Accept header. They just send */*

    IE seems to send

    x-flash-version
    

    with flash requests for some stupid reason...

    0 讨论(0)
提交回复
热议问题