Jquery:通过单击 Div 触发嵌入对象单击?

发布于 2024-09-24 15:44:22 字数 2612 浏览 0 评论 0原文

我试图通过单击另一个 div 来触发嵌入对象单击,

这是我尝试过的代码:

$('.action-upload').livequery(function()
{
 $(this).click(function()
 {
     $('#button').trigger('click');

 });

}); 

这是 firebug 中嵌入对象的代码:

<object width="114" height="29" class="swfupload" data="js/swfupload/swfupload.swf?preventswfcaching=1285336584999" type="application/x-shockwave-flash" id="SWFUpload_0">(parameters)</object>

这就是我的 html 文档中的代码,

<input type="button" id="button" />

我不确定如果我应该尝试触发表单按钮或对象,我猜测该对象是因为它在页面呈现时不显示为按钮,而是显示为嵌入对象?

我在正常输入按钮上使用了该代码,该按钮有效,但是当我将其应用到此时,没有

人知道我将如何做到这一点?

( actions-upload div 只是一个带有 bg 图像的普通 div )

感谢您的时间;)

编辑了更多信息:

这是我在 html 中使用的脚本,

$('.action-upload').live(function()
{
    $(this).click(function()
    {
        $('#button').trigger('click');
    });         
});

是 html:

<div class="action-upload">(bg image)</div>

<div id="swfupload-control">

<input type="button" id="button" />

    <ul id="log"></ul>

</div>

这里 是什么取代了浏览器中的表单按钮(从 firebug 获得)

<object width="114" height="29" class="swfupload" data="js/swfupload/swfupload.swf?preventswfcaching=1285348248401" type="application/x-shockwave-flash" id="SWFUpload_0"><param value="window" name="wmode"><param value="js/swfupload/swfupload.swf?preventswfcaching=1285348248401" name="movie"><param value="high" name="quality"><param value="false" name="menu"><param value="always" name="allowScriptAccess"><param value="movieName=SWFUpload_0&amp;uploadURL=%2Fupload-file.php&amp;useQueryString=false&amp;requeueOnError=false&amp;httpSuccess=&amp;assumeSuccessTimeout=0&amp;params=&amp;filePostName=uploadfile&amp;fileTypes=*.jpg%3B*.png%3B*.gif%3B*.pdf%3B*.html%3B*.ai%3B&amp;fileTypesDescription=Image%20files&amp;fileSizeLimit=5000&amp;fileUploadLimit=10&amp;fileQueueLimit=0&amp;debugEnabled=false&amp;buttonImageURL=%2Fjs%2Fswfupload%2Fwdp_buttons_upload_114x29.png&amp;buttonWidth=114&amp;buttonHeight=29&amp;buttonText=&amp;buttonTextTopPadding=0&amp;buttonTextLeftPadding=0&amp;buttonTextStyle=color%3A%20%23000000%3B%20font-size%3A%2016pt%3B&amp;buttonAction=-110&amp;buttonDisabled=false&amp;buttonCursor=-1" name="flashvars"></object>

我正在使用 swfupload 并尝试从 actions-upload div 触发嵌入对象“click”

I am trying to trigger an embedded object click by clicking on another div,

this is the code ive tried:

$('.action-upload').livequery(function()
{
 $(this).click(function()
 {
     $('#button').trigger('click');

 });

}); 

this is the code that comes up for the embedded object in firebug:

<object width="114" height="29" class="swfupload" data="js/swfupload/swfupload.swf?preventswfcaching=1285336584999" type="application/x-shockwave-flash" id="SWFUpload_0">(parameters)</object>

this is what the code is like in my html document

<input type="button" id="button" />

im not sure if im supposed to be trying to trigger the form button or the object, im guessing the object as it doesnt appear as a button when the page renders, it appears as an embedded object?

i used the code on a normal input button which works, but when i apply it to this it doesnt

anyone got any ideas how i would do this?

( the actions-upload div is just a normal div with a bg image )

thanks for your time ;)

edited for more info:

here is the script i use in the html

$('.action-upload').live(function()
{
    $(this).click(function()
    {
        $('#button').trigger('click');
    });         
});

here is the html:

<div class="action-upload">(bg image)</div>

<div id="swfupload-control">

<input type="button" id="button" />

    <ul id="log"></ul>

</div>

and this is what replaces the form button in the browser (got this from firebug)

<object width="114" height="29" class="swfupload" data="js/swfupload/swfupload.swf?preventswfcaching=1285348248401" type="application/x-shockwave-flash" id="SWFUpload_0"><param value="window" name="wmode"><param value="js/swfupload/swfupload.swf?preventswfcaching=1285348248401" name="movie"><param value="high" name="quality"><param value="false" name="menu"><param value="always" name="allowScriptAccess"><param value="movieName=SWFUpload_0&uploadURL=%2Fupload-file.php&useQueryString=false&requeueOnError=false&httpSuccess=&assumeSuccessTimeout=0&params=&filePostName=uploadfile&fileTypes=*.jpg%3B*.png%3B*.gif%3B*.pdf%3B*.html%3B*.ai%3B&fileTypesDescription=Image%20files&fileSizeLimit=5000&fileUploadLimit=10&fileQueueLimit=0&debugEnabled=false&buttonImageURL=%2Fjs%2Fswfupload%2Fwdp_buttons_upload_114x29.png&buttonWidth=114&buttonHeight=29&buttonText=&buttonTextTopPadding=0&buttonTextLeftPadding=0&buttonTextStyle=color%3A%20%23000000%3B%20font-size%3A%2016pt%3B&buttonAction=-110&buttonDisabled=false&buttonCursor=-1" name="flashvars"></object>

i am using swfupload and am trying to trigger the embedded object "click" from the actions-upload div

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零崎曲识 2024-10-01 15:44:22

如果我理解正确的话,您正在尝试让嵌入的 Flash 对象触发 HTML 按钮上的单击事件 ()。

仅使用 jQuery 无法完成此任务。 Flash 对象上的点击由 Flash 对象处理。要执行您所要求的操作,您需要修改 Flash 源以对 JavaScript 进行外部调用。如何完成此操作很大程度上取决于您用来构建文件的 Flash/ActionScript 版本。

ActionScript 3 有一个 ExternalInterface 类,您可以用于调用外部 JavaScript 函数。在 ActionScript 3 文件中,它看起来类似于以下内容...

在元素的单击处理程序中,调用 JavaScript 匿名函数:

ExternalInterface.call("function(){$('#button').trigger('click');}");

如果您自己不控制 Flash 对象,您可能无法执行您所要做的事情试图做。

If I understand correctly, you are trying to have an embedded Flash object trigger a click event on an HTML button (<input type="button" ...>).

You will not be able to accomplish this using jQuery alone. Clicks on the Flash object are handled by the Flash object. To do what you're asking, you would need to modify the Flash source to do an external call to the JavaScript. How you accomplish this is largely dependent on what version of Flash/ActionScript you're using to build the file.

ActionScript 3 has an ExternalInterface class which you can use to call external JavaScript functions. In the ActionScript 3 file, it would look something like the following...

Inside the element's click handler, call a JavaScript anonymous function:

ExternalInterface.call("function(){$('#button').trigger('click');}");

If you don't control the Flash object yourself, you may not be able to do what you're trying to do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文