8

Please provide an example of how to use the object tag in an HTML form.

I was reading the HTML5 spec today to learn what kind of form elements exist nowadays, and noticed the following:

Submittable elements

Denotes elements that can be used for constructing the form data set when a form element is submitted: button, input, keygen, object, select, textarea http://www.w3.org/html/wg/drafts/html/master/forms.html#category-submit

So apparently a form can have an object tag in it, affecting the data that is sent on form submission. The only context in which I was familiar with the object tag is to embed Flash movies onto a page. What would be an example situation where you could use the object tag in a form and have it affect the form submission data?

Update:

In the spec on how form payload is constructed on submit, found this interesting snippet in http://www.w3.org/html/wg/drafts/html/master/forms.html#constructing-form-data-set

If the field element is an object element: try to obtain a form submission value from the plugin, and if that is successful, append an entry to the form data set with name as the name, the returned form submission value as the value, and the string "object" as the type.

But I wonder what kind of plugins hand out such submission values.

Update:

QtBrowserPlugin seems to support using them in forms. Now all I need for an example is a minimalistic such plugin.

http://doc.qt.digia.com/solutions/4/qtbrowserplugin/developingplugins.html#using-plugins-in-forms


PHPStorm & PHPUnit - Unable to attach test reporter to test framework

When running "Debug" in phpstorm on my project, for some reason it's started having this weird problem where phpstorm doesn't really pick up the test results, even though phpunit is not throwing an error.

Phpunit will generate a report in the phpstorm console that looks something like this:

[37;41m[2KFAILURES!
[0m[37;41m[2KTests: 3, Assertions: 6, Failures: 1.
[0m[2KGenerating code coverage report in Clover XML format ... done

Process finished with exit code 1

I'm guessing phpstorm can't interpret these results? It was working before and it would be nice to have full integration again.

Any help would be great

4

2 に答える 2

1

最初に、HTML5.1 ではなく、http://www.w3.org/html/wg/drafts/html/CR/forms.html#constructing-form-data-setにある最新の HTML5 ドキュメントを使用することをお勧めします。

現在、この動作を実装しているブラウザはありません。いずれにせよ、仕様に書かれていることを真似したい場合は、次のようなスクリプトを使用できます。

<!DOCTYPE html>
<html>
<body>
<form method="post" action="index.html" id="myForm">
    <input type="text" id="myFieldID" name="myFieldName" value="Hello World!" />
    <object type="myPluginMIMETYPE" id="myPluginID" name="myPluginName" ></object>
    <button type="submit">Submit</button>
</form>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
$( document ).ready(function() {
    $( myForm ).on( "submit", function( event ) {
        //Ask the plugin for some data, i.e. a flash object
        var pluginData = "pluginImportantData"; // ideally something like $(myPluginID).giveMeSomeDataBecauseUserWantsToSubmit();
        //Append the data before submission, giving to the input tag the right attributes
        $(this).append('<input type="object" name="myPluginName" value="'+ pluginData +'" style="visibility:hidden"/>');
        return true;
    });
});
</script>
</body>
</html>
于 2013-11-27T15:56:33.207 に答える
-1

試してみた後、もう一度考えてみると、オブジェクトを表示できるようにするクレチンタグを見逃していない限り、オブジェクトタグをフォーム内に配置しても機能しないようです。ただし、div タグを使用してオブジェクトを区切ることができます。次のことを試してみました。最初のセクションは正常に機能します。「フォーム」で始まるセクションはfire foxに表示されないため、記述時に何かを見逃した可能性があります。EDIT= 削除されたリンク (役に立たない)

    <!DOCTYPE html>
    <html>
    <body>

    <object width="400" height="400" data="file name.***"></object>
    <div>
    <object width="500" height="500" data="file name.***"></object>

    <form>
    <object width="500" height="500" data="1r.txt">
    <object width="500" height="500" data="2r.txt">
    </object>
    </object>
    </form>

    </body>
    </html>
于 2013-10-04T18:34:46.143 に答える