Php 从iFrame中提取url变量
我正在使用run API上的位来上传视频,问题是我必须将上传表单包含到iframe中,上传表单将上传视频,完成后将重定向到另一个页面,视频id作为url变量 我试图做的是在上传完成时从iframe获取url变量 以下是iframe示例:Php 从iFrame中提取url变量,php,javascript,iframe,Php,Javascript,Iframe,我正在使用run API上的位来上传视频,问题是我必须将上传表单包含到iframe中,上传表单将上传视频,完成后将重定向到另一个页面,视频id作为url变量 我试图做的是在上传完成时从iframe获取url变量 以下是iframe示例: <iframe width="650" scrolling="auto" height="220" frameborder="0" src="http://developer.longtailvideo.com/botr/demo/upload/">
<iframe width="650" scrolling="auto" height="220" frameborder="0" src="http://developer.longtailvideo.com/botr/demo/upload/"></iframe>
上传完成后,iframe将重定向到:
<iframe width="650" scrolling="auto" height="220" frameborder="0" src="http://developer.longtailvideo.com/botr/demo/upload/show.php?video_key=xxxxx"></iframe>
如果xxxxx是我想在父页面中提取的视频密钥,我将在隐藏输入中使用此视频密钥,以便提交另一个表单
当重定向发生时,有三种方法可以获取此url变量吗?尝试以下方法:
ifr=document.getElementById('Your_Iframe_Id');
ifr.contentWindow.onload=function (){
ssearch=ifr.contentWindow.location.search; // = ?video_key=xxxxx
/* do something with ssearch */
return;
}
在这种情况下,计时非常重要,因为ifr.contentWindow
在首次加载之前不存在。我建议您首先将一个页面从服务器加载到IFRAME
,然后将onload
-eventhandler从该页面分配到主机页面
或者,您可以等待整个主机页加载(window.onload
),然后为ifr.contentWindow
分配事件处理程序