你要做的是:
- 使用 iframe 播放器(下载 shadowbox 时,您必须选中“外部站点和页面”-复选框)
- 为 onFinish 提供一个回调函数,以确保 iframe 在真正提交表单之前存在
- 将表单的目标属性更改为sb-player(即 shadowbox 创建的 iframe 的名称)
示例代码(将在影子框中运行谷歌搜索)
<script type="text/javascript">
Shadowbox.init();
$(function()
{
$('form')
.submit(function()
{
//reference to the form, needed in onFinish
var me=this;
Shadowbox.open({
//we dont need to load a page
content: 'about:blank',
//use the iframe-player
player: 'iframe',
height: 350,
width: 850,
options: {
//send the form without
//triggering the submit-event
//when the iframe is available
onFinish:function()
{me.submit();}
}
});
//set the iframe(the name is sb-player) as target of the form
$(this).attr('target','sb-player');
return false;
});
});
</script>
<form action="http://google.de/search">
<input name="q" value="shadowbox">
<input type="submit">
</form>