あなたがしなければならないことは次のとおりです。
- iframe-player を使用します (シャドウボックスをダウンロードするときは、[外部サイトとページ] チェックボックスをオンにする必要があります)。
- フォームを実際に送信する前に iframe が存在することを確認するために、onFinish のコールバック関数を提供します。
- フォームの target-attribute をsb-playerに変更します(これは、shadowbox によって作成された iframe の名前です)
コード例 (シャドーボックスで Google 検索を実行します)
<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>