在访问iframe内容时需要帮助 [英] Need help in accessing contents of iframe

查看:48
本文介绍了在访问iframe内容时需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,我试图更改iframe中的文本框的值,但是如果iframe src在相同的域中,则此代码有效,如果在以下情况下这些域不同,该怎么办?

this is my code i m trying to change the value of a textbox which is in iframe but this code works if the iframe src is in same domain what should i do if the domains are different as in the following scenario?

<script type="text/javascript" src="jquery.js"></script>
<script>
$(document).ready(function()
{
    $("#abcweb").contents().find('input[name$="login"]').val("name");
});
</script>
        <div class="header">
            <h1> ABC </h1>
        </div>
        <div class="main">
            <iframe src="http://abc.com/agents/" id="abcweb"></iframe>
        </div>
        <div id ='tdiv'>
            </div>
    </body>
</html>

推荐答案

(document).ready(function() {
(document).ready(function() {


(#abcweb").contents().find('input [name
("#abcweb").contents().find('input[name


="login"]').val( 姓名"); }); < /script > < div =" 标题" < h1 > ABC < /h1 > < /div > < div =" main" < iframe =" http://abc.com/agents/" id =" abcweb" < > < /div > < div =' tdiv' > < /div > < /body > < /html >
="login"]').val("name"); }); </script> <div class="header"> <h1> ABC </h1> </div> <div class="main"> <iframe src="http://abc.com/agents/" id="abcweb"></iframe> </div> <div id ='tdiv'> </div> </body> </html>


这篇关于在访问iframe内容时需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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