jayjayfinney Posted July 10, 2010 Share Posted July 10, 2010 Hello, I've lately brought a new search engine scirpt however I was wonder how i could grap what ever the url is being viewed in the iframe, in order to create a hyperlink button which wil take the user to what ever is displayed in the iframe, but without my frame? Very simplilar to the 'remove frame' link that google images has on it's search result pages. My php code for my iframe is as follows; ?> <iframe src='<?php echo $myval; ?>' id="frame<?php echo $position_id; ?>" onload="frameload(<?php echo $position_id; ?>)" scrolling="yes" width="100%" frameborder="0" height="85%"></iframe> <?php Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/ Share on other sites More sharing options...
pornophobic Posted July 10, 2010 Share Posted July 10, 2010 I can't really show you how to do this one precisely, but I can give you a few ideas of what you'd want to do to accomplish what you're trying to do since you just gave the code for the iframe. So I can't give you any code, but I can give you hints as to what to do in your own code. I'm imagining you have two frames like google does when you view images through them. In YOUR frame, that is the source page for your frame. Not the frame itself, you'll have to set the variable for the url there, or get the url from the iframe somehow. Say you have it set as $myvar in your example code you would just need to add into the source for your frame something like echo "<a href='$myvar' alt='view page'>View page</a>"; Though, that's a really vague description of code you gave, so I guess I can only really give a vague answer... sorry. Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084205 Share on other sites More sharing options...
jayjayfinney Posted July 10, 2010 Author Share Posted July 10, 2010 Many Thanks for your reply. If i attach you the page with the frame on, as i'm new to all this PHP coding. Thank you [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084208 Share on other sites More sharing options...
.josh Posted July 10, 2010 Share Posted July 10, 2010 if the iframe url is changing, you can't grab the current one with php. You will have to use javascript (client-side scripting). Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084220 Share on other sites More sharing options...
jayjayfinney Posted July 10, 2010 Author Share Posted July 10, 2010 :-\ Crayon Violent could you possibly help me on that? I have completly no idea how to do it, please could you help me by any chance? many thanks Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084225 Share on other sites More sharing options...
pornophobic Posted July 10, 2010 Share Posted July 10, 2010 if the iframe url is changing, you can't grab the current one with php. You will have to use javascript (client-side scripting). Yep, after looking at that I realized this. I thought it was two iframes on the same page, but the header is a div with an iframe for each tab. It wouldn't be hard to do, although I don't think this would be the right forum for this...? Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084226 Share on other sites More sharing options...
jayjayfinney Posted July 10, 2010 Author Share Posted July 10, 2010 Could you help me with what needs doing by any chance Pornophobic? Please?? Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084228 Share on other sites More sharing options...
.josh Posted July 10, 2010 Share Posted July 10, 2010 actually I lied... I thought if you just did like document.getElementById("iframeidhere").src it would give you the current url but it will only give you the initially loaded url in the iframe, so if the user is navigating to other places within the iframe, you can't grab that value. If the currently loaded page is on the same domain as the main page then you can use (IE) document.getElementById("iframeidhere").contentWindow.location.href (other browsers) document.getElementById("iframeidhere").contentDocument.location.href But if the currently loaded page is not on the same domain as the parent then it is considered cross-site scripting and is not allowed (will throw you an error) - so you are just shit out of luck if that is what you are needing. Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084234 Share on other sites More sharing options...
jayjayfinney Posted July 11, 2010 Author Share Posted July 11, 2010 Well will any sort of Javascirpt work or not? Quote Link to comment https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084403 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.