简体   繁体   中英

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). That iframe page is to be opened only in a pseudo or a trial mode in 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?

Thanks.

Why not use a querystring in the src attribute of P1's iframe which passes the boolean that dictates how P2 behaves? Then, use some server-side script in P2 to grab the variable from the querystring and handle it accordingly before the page loads?

eg:

P1 code:

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

P2 code:

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

    //Build trial page

} else {

    //Build normal page

} ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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