简体   繁体   English

在子iframe的$ {document).ready函数被调用之前进行预处理

[英]Pre-processing before child iframe's $(document).ready function is called

My page (lets call it P1) has an iframe in which I load another html page (P2). 我的页面(我们称其为P1)具有一个iframe,我在其中加载了另一个HTML页面(P2)。 That iframe page is to be opened only in a pseudo or a trial mode in P1. 该iframe页面仅在P1中以伪或试用模式打开。

From P1's scope, is it possible to access P2's scope and mark a boolean variable before P2's $(document).ready() function is called using the iframe's contentWindow look-up or otherwise? 从P1的范围来看,是否可以在使用iframe的contentWindow查找调用P2的$(document).ready()函数之前,访问P2的范围并标记一个布尔变量?

Thanks. 谢谢。

Why not use a querystring in the src attribute of P1's iframe which passes the boolean that dictates how P2 behaves? 为什么不在P1的iframe的src属性中使用查询字符串,该字符串传递指示P2行为方式的布尔值? Then, use some server-side script in P2 to grab the variable from the querystring and handle it accordingly before the page loads? 然后,在P2中使用某些服务器端脚本从查询字符串中获取变量,并在页面加载之前进行相应的处理?

eg: 例如:

P1 code: P1代码:

<iframe src="http://example.com/p2.html?mode=trial"/></iframe>

P2 code: P2代码:

<?php if ($_GET['mode'] == trial)
{

    //Build trial page

} else {

    //Build normal page

} ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM