iframe将焦点设置为父级 [英] Iframe set focus to parent

查看:51
本文介绍了iframe将焦点设置为父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

在这个项目上工作,我在主页面中有一个iframe,如下所示

 <   div     

< form > < / form >
< iframe 名称 = ifmjax id = ifmjax src = http:// localhost:85 / jaxVIEW.html?jaxURL =@Model.jaxUrl > < / iframe >
< 输入 类型 = text id = idOfInput value = / >
< / div >



jaxVIEW.html

 <  !DOCTYPE     HTML     PUBLIC    < span class =code-attribute> -  // W3C // DTD     HTML     4.0     Transitional // EN >  
< html >
< head >
< title > 新文档< / title >
< script src = http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js > < / script >
< script src = http:// localhost:61687 / Scripts / Payments.js > < / script >
< script < span class =code-attribute> src = http:// localhost:61687 / Scripts / tpp.js type = text / javascript > < / 脚本 >
< script type = text / javascript >
function PostAuth(){
debugger ;
alert(' PostAuth');
window .parent。 document .getElementById( idOfInput)。focus();
return true ;
}
< / 脚本 >
< / head >

< 正文 >

< div class = content id = content >
< div class = cardBox id = cardtBox >
< div id = main > < / div >
< / div >
< / div >
< / body >
< / html >
< / html >



在ifram主div上根据jaxURL值填充html,这是从payment.js文件中调用的。

我想要的一旦在iframe中完成了所有转换,它应该关注父页面以加载事务确认页面。但它正在加载到iframe

如何将确认页面加载到父页面?

感谢所有帮助

解决方案

您可以在父页面中调用JS函数,代码如下:



 窗口 .parent.functionName(); 


Hi there
Working on this project where I got an Iframe inside the main page as bellow

<div 

    <form >    </form>
    <iframe name="ifmjax" id="ifmjax" src="http://localhost:85/jaxVIEW.html?jaxURL=@Model.jaxUrl"></iframe>
   <input type="text" id="idOfInput" value=" " />
</div>


jaxVIEW.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> new document </title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://localhost:61687/Scripts/Payments.js"></script>
<script src="http://localhost:61687/Scripts/tpp.js" type="text/javascript"></script>
 <script type="text/javascript">
function PostAuth() {
    debugger;
    alert('PostAuth');
    window.parent.document.getElementById("idOfInput").focus();
    return true;
}
</script>
</head>

<body >

<div class="content" id="content">
<div class="cardBox" id="cardtBox">
 <div id="main"></div>
 </div>
 </div>
</body>
</html>
</html>


On the ifram main div is populated with a html according to the jaxURL value this is called from payment.js file.
I wanted once the all the transition is completed in the iframe it should focus to parent page to load the transaction acknowledgement page. But it is loading in to the iframe
How can I get the acknowledgement page to load in to parent page?
Appreciate all your help

解决方案

You can call a JS function in your parent page with code like this:

window.parent.functionName();


这篇关于iframe将焦点设置为父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆