neridaj Posted September 2, 2008 Share Posted September 2, 2008 Hello, I have an iframe contained within a page whose source page includes a call to a function that accesses a $_GET[] superglobal. is there some sort of "parent" function I need to call to have this var accessible to the iframe calling function? The iframe src page works without relying on variables i.e., the page is populated as expected with thumbnails, however, I need to separate which thumbnails are loaded based on the $_GET[] var. // iframe src - thumbs.php <? get_main_thumbs(); ?> // page containing iframe - portfolio.php <div id="thumbs"> <iframe id="ifrm" name="ifrm" src="thumbs.php" scrolling="auto" width="600" height="94" frameborder="0"> [Content for browsers that don't support iframes goes here. Suggestion: include link to file specified in iframe src attribute.] </iframe> </div> // function function get_main_thumbs() { $projecttype = $_GET['pt']; $dir = '../projects/' . $projecttype . '/'; echo $dir; $files = scandir($dir); foreach($files as $value) { if(!in_array($value, array('.', '..'))) { // check for folders if(is_dir($dir.DIRECTORY_SEPARATOR.$value)) { printf('<div class="thumb"><a href="portfolio.php?pt=%s&pn=%s" target="contents">'. '<img src="' . $dir . $value . '/after/' . $value . '01.jpg" width="50" height="50" /></a></div>', $projecttype, urlencode($value)); } } } } Thanks, Jason Link to comment https://forums.phpfreaks.com/topic/122422-accessing-global-vars-from-iframes/ Share on other sites More sharing options...
BlueSkyIS Posted September 2, 2008 Share Posted September 2, 2008 if i understand correctly, you want to modify the source of the iframe, including a get variable to define what thumbs are shown. if so, i would append the get var on the end of the iframe source: src='thumbs.php?images=<?php echo $images_2; ?>' Link to comment https://forums.phpfreaks.com/topic/122422-accessing-global-vars-from-iframes/#findComment-632136 Share on other sites More sharing options...
neridaj Posted September 5, 2008 Author Share Posted September 5, 2008 Thanks for the reply. I did this which works, but when I click on the thumbnails everything is loaded into a new window. function get_main_thumbs() { $projecttype = $_GET['pt']; $projectname = $_GET['pn']; $dir = '../projects/' . $projecttype . '/'; $files = scandir($dir); foreach($files as $value) { if(!in_array($value, array('.', '..'))) { // check for folders if(is_dir($dir.DIRECTORY_SEPARATOR.$value)) { printf('<div class="thumb"><a href="portfolio.php?pt=%s&pn=%s" target="contents">'. '<img src="' . $dir . $value . '/after/' . $value . '01.jpg" width="50" height="50" /></a></div>', $projecttype, urlencode($value)); } } } } How can I make the link just load the data in the same browser window? Thanks, Jason Link to comment https://forums.phpfreaks.com/topic/122422-accessing-global-vars-from-iframes/#findComment-634732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.