Home > Web Front-end > JS Tutorial > Call the iframe page based on ID (code attached)

Call the iframe page based on ID (code attached)

php中世界最好的语言
Release: 2018-04-26 15:34:31
Original
1708 people have browsed it

This time I will bring you the call to the iframe page based on the ID (with code). What are the precautions for calling the iframe page based on the ID? The following is a practical case, let's take a look.

$(window.parent.
document
).contents().find("#iframeID")[0].contentWindow.initPagerList();
Copy after login

Description:

iframeID is the ID of the iframe;

initPagerList is the method in the iframe page.

<html>
<head>
 <title></title>
 <script>
  $(function(){
    /*
     说明: iframeID 为iframe的ID;
     initPagerList 为 iframe 页面内的方法。
    */
    //调用iframe页面iframeID中的initPagerList方法
    $(window.parent.document).contents().find("#iframeID")[0].contentWindow.initPagerList();
    //获取iframe页面iframeID中的文本框txtControlID对象
    var txtControlObj=$(window.parent.document).contents().find("#iframeID")[0].contentWindow.find("#txtControlID");
    //为iframe页面iframeID中的文本框txtControlID赋值
    txtControlObj.val("我就是你需要设置的内容值!");
  });
 </script>
</head>
<body>
</body>
</html>
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How does jquery make iframe adaptive to the front-end height

jquery js calls the iframe parent window and child window Detailed explanation of steps

The above is the detailed content of Call the iframe page based on ID (code attached). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template