Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084205
Share on other sites

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...?

Link to comment
https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084226
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/207372-ulr-with-iframes/#findComment-1084234
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.