Jump to content

get url of iframe's parent page onto the iframe page


antonyfal

Recommended Posts

Im battling a bit here:

I got a main page html with an iframe "mainframe".. Inside the mainframe i have portaed another script from my server... This script has its own url within the iframe..

 

What i need to to is get the parent url explode the url and see if any parts are ==tmpl=component, then if success the iframe page loads a hidden input <input type="hidden" name="tmpl" value="component"/> else ""

 

What problems im having:

the site works on both in the iframe and on its own normally..

 

//this code is on the search.html the page loaded within the iframe-- i need to get the parent url, and see if it contains "tmpl=component" then if it does loads the hidden input..

 

note: the search page is also called from the normal index.php page and is then not in an iframe--

 

<?php

        $parenturl = $_SERVER['REQUEST_URI'];

        $parts = explode("?", $parenturl);

        If ($parts=='tmpl=component'){

<input type="hidden" name="tmpl" value="component"/>

}

?>

 

 

I'm going to say thats not highly likely (I could be wrong) But generally speaking PHP is a server side language. It renders once and its done. I know there's ways you can crawl your DOM elements and find a particular elements attributes and values there of. But I don't know how effect that is, I've never done that myself without using JavaScript at some level of the process.

 

But you are also talking 2 individual frames. Usually what loads in one, isn't read through the other. They are independent of one another in a matter of speaking. Though again if you control both pages framed and otherwise you can pass information from one to the other with JavaScript then process any information via AJAX methods.

Thanks.

What you are saying makes sense. Do you know of any place to look for a snippet or a resolution to this "what i thought would be easy" problem?

I tried several javascript snippets but no luck-- it was also surprising to see how many people also had this problem..

If i find a solution ill post it here.. if anyone else has a solution this would also be gr8.

Regards

Tony

 

I been going about it the wrong way..

 

the search page is accessed in two ways using 2 different urls:

// this loads the search with all the mainsites pages 

main url: www.xxxx.com/xxx/xxxx/xxxx/search.html

 

then in a iframe like this:

//this loads only the search page without the rest of the main page

http:///www.xxx.com/xxx/xxx/xxx/search.html?tmpl=component

i use this in the iframe on the main page.

I need to add the following script to the search page to determin if the "tmpl=component"

is in the url, if it is!? then it must continue to load it-- with this hidden input:

 

<input type="hidden" name="tmpl" value="component"/>  // but my snippets not working.. i dont need the parent url, only the current iframe url

 

heres my code:

 

</head>

<body>

<?php

 

        $url = $_SERVER['REQUEST_URI'];

echo $url;

        $parts = explode("=", $url);

        If ($parts==component){

<input type="hidden" name="tmpl" value="component"/>

}else{echo "";}

?>

</body>

</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.