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


OpenMP optimize scheduling of for loop

I need some help with OpenMP. Is it possible that if a thread ended in a for loop it helps then to another thread, dividing it? I have a loop in a loop where are breaks; and the threads doesn't end at the same time, so there are threads which has much work, and other threads which are done. (so there are unused cores). I run my program on a corei7, and it seems that OpenMP divide the loop to 8 threads. But the utilization starts to drop after some time when one thread did the job.

#pragma omp parallel for
for(i = 0; i < Vector.size(); i++) {
    for(j = 0; j < othervector.size(); j++) {
        {some code}
        if(sth is true) break;
    }
}

Thank you.

4

2 回答 2

1

首先,我建议使用http://www.w3.org/html/wg/drafts/html/CR/forms.html#constructing-form-data-set上的最新 HTML5 文档,而不是 HTML5.1 文档。

我担心目前没有浏览器可以实现这种行为。在任何情况下,如果你想模仿规范所说的,你可以使用这样的脚本:

<!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

在尝试之后再想一想,似乎将对象标签放在表单中是行不通的,除非我可能错过了允许对象可见的 cretin 标签但是您可以使用 div 标签来分隔对象。我尝试了以下方法,第一部分工作正常,以“表单”开头的部分没有出现在火狐中,所以我可能在编写时遗漏了一些东西。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 回答