Open link inside of a iframe in new window within the iframe - php

I have this:
Div element (like a bar, with some text and a logo)
Iframe with a page that I cannot modify (in this example: google.com)
What I need is to "catch" (or anything else), all links that user click with mouseweel (or right click it and open it in new window), then, open that link in another window with a div element and an iframe which loads the link inside the iframe, I mean, in a new page exactly like the first, with the div and the iframe.
If user clicks normally any link, it just opens the link inside the iframe (as iframe usually does).
I've found a code that changes all links in website and it opens all of them in new window referring the url of the link to PHP with a parameter, but I don't want to open all links in new window, by default all links in the page it opens inside of a iframe (_self) in html, but if the user wants to open it in new window, I want to allow that, but opening it new window with a div element and an iframe which loads the link inside the iframe...

It is not possible to interact with anything in iframe within different domain. You must use HTTP PHP proxy that will edit the page you display so all links DO redirect on your site.
So the solution would be to have a PHP script that downloads the site you display in iframe, chang ALL links from http://differentsite.com/path/file.php to http://mysite.com/script.php?path=path/file.php so that if the user clicks the link, he gets in your IFRAME view again.
This is how HTTP proxies do work.

From your current question, I understand that you want links to NOT open in a new tab, and to replace the page currently open in the iframe.Short answer: not possible.Full answer:1) Links using target="_blank" cannot be edited inside an iframe hosted on a separate site. This is because of the Same Origin Policy.2) In theory, you cannot ever override what the user wants, even if you could control the iframe content. Specifically, when a user clicks "open in a new tab," this can never be overridden.

Related

Keeping a link inside a iframe

I am trying to use Iframes and or PHP to hide a link that is dynamically created. The link is being created in php. But when I try to access that link from within an iframe it takes over the whole page. The site loads, but the idea is that if it was in an iframe the url could be hidden and the user could click multiple items with out having to enter all their form data in every time.
I've tried using the link as a header and using php commands like:
$remote = fopen( $URL, "r");fpassthru($remote);
where $URL was my link.
a sample of the link is:
http://fb-zc-0.cafe.zynga.com/current/iframe//mfs_sent.php?ids=2&tab_clicked=All&request_id=236973056431070&gid=3014&today=1&time=3&ref=gift_today&cafe_token=OAlF7gSlMbQxAtBhvnprTzNhIww8H7Aq2z9i3KJwGWmJzUQfxZ8b9/kFWMVqN62JUihQA06VtuuoKoxmosK6JIPKWTMl0oQecLb+0e0HSAk3S32f5BCI7xhYB9SflOnN&from_page=SUNRISE_BREAKFAST_1&kingdom=quest&phylum=baklava&uid=342&sendkey=8e4aa1a75594c47cc61aee301efff90e$$ccF(NUP,67jiH3QM7!nspE0W8d8KprzD5,Za77bp34G*S_ST)*ilx)F7Y)acC4xj971Kkswxx2OM3eij3z1h0M3eij3z1h0&mode=quest_asking&quest_key=SUNRISE_BREAKFAST_1&mfs_time=3&snood=1&ajax=true&limiter_channel=rsvp&limiter_type=build_a_carnival3+5
Any help would be appreciated.
If you have links outside of this iFrame and want them to load into that iFrame on the same page, you'll have to give it a name, then target the named iFrame within your link's href.
<iframe src="http://google.com" name="myframe" hieght="100" width="100"></iframe>
<br/>
Test.
However, if you're loading a page into your iFrame that's loading links with target="blank", then those will go to a new window; unless you don't have access to those pages, you won't be able to change the links (short of writing JS to dive into your iFrame, etc).

iframe and header location issue

I am using an iframe under which another small application is running on. In one certain page of the iframe, I try to redirect the url to parent's index page. But if I am using header('location:fullpath/index.php'). then it is redirecting to the mentioned page, but within the iframe. I need it will be opened beyond the iframe. Could you please help me to fix up this issue?
If you don't want to use javascript and you have control over the target page, you can put this metatag at the top of the target page and it should open in a new window.
<META HTTP-EQUIV="Window-target" CONTENT="_blank">
Here is a list of the other CONTENT options you can try as I'm not certain what beyond the iframe means.
Same Frame -_self
Whole Page -_top
New Window -_blank
Parent Frame-_parent

Can I load a domain in my iFrame and when you click a link, it opens in the parent window, not the iframe?

Similar to Stumbleupon, if you load random domains (ones that I do not own) and want to have the links within that page not just change within the iframe, but change on the parent url.
If that's hard to understand here's more layman terms:
URL: mywebsite.com/reddit.com
opens iframe on my website showing: reddit.com
click link within the iframe (showing reddit.com).
rather than it loading the new page in the iframe, can it load in the parent window at mywebsite.com/reddit.com/newlink
which would then open the iframe in my website, but would allow me to track what URL is being view and thus allowing me to perform my site-specific functionality.
Thanks!
in short, it cant happen. external sites are made to open links relative to their sites. there is no way to accomplish this.
you can set the link target to _top. <a href='www.someothersite.com' target='_top'>Link</a>
edit: Sorry, mis-read something. You can not edit the page on the other site through the iframe to change the target of the links. This is why on places like google images or stumbleupon they have an "X" in the corner that takes you to the page in the iframe.
If you could modify external pages, that would be a major phishing security risk as anyone could then make a page that is just an iframe to your bank but collects whatever you type into the username/password boxes.
In the old days if you made a page with frames you could specify what section your links took you to. Modifying links that aren't under your control is possible but rather a task and a half.
To use frames you could specify your target= within your tag. Each frame is named on creation to make it easy.
That's an old approach. Hope it helps

Make an external link to an iFrame in a webpage

I have a page with an iFrame in it. I want to be able to send links to people, that will open a page within that iFrame on my page.
The main (parent) page is called results.html
The iFrame has the id "searchresults"
The page that I wan people to be able to open within that iFrame is results.php, but it would have a number of parameters in it (for example results.php?id=5)
How would I construct the link to send to people?
For example, would it be /results.html?target="searchresults";?results.php?id=5
I simply can't work it out!
What stops you from simply loading the iFrame and the main frame with the same GET parameters?
Or the place where you add iFrame, simply add the GET parameters of the main page also to the iFrame and then check for their presence in the iFrame code?
For example, I have a page:
index.php
In this page I have an iFrame with an URL:
<iframe src="search.php"></iframe>
If I make a search, then the main page would change:
index.php?search=test
Now when I am generating the iFrame URL, I check if that GET parameter exists, if it exists then I append it to iFrame URL:
<iframe src="search.php?search=test"></iframe>

Styling messed up when page is open in new tab

I have a login form that opens in a fancybox. My problem is that when the user just clicks on the link nothing wrong happens, but when he opens it in a new tab, the style is messed up, because the page is designed to be minimal (only login form with forgot password link).
How can I make the link on fancybox, not the same as when opened in a new tab?
Can I detect it in PHP (server side)?
Or can I set fancybox to open a different location on clicking on the link ?
I suggest you pass a variable to the login window when the user clicks normally that indicates the page was loaded normally and then server side you decide which CSS to load based on the presence of the variable. That way you can accommodate both cases.

Categories