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>
Related
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).
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.
What I currently have:
index.php: Mainpage, showing topbar, navigation & placeholder for content
navigation: uses javascript to load a php-file into the content-section from index.php if a link in the navigation is clicked; important: NO refresh of index.php
Is working fine right now. Also the url in the address bar is not being changed right now when clicking a link.
What should be added:
If a link in the navigation is clicked, javascript should still load a php-file but also should change the url in the address bar without refreshing the side.
Example:
url: "www.example.com
In navigation link "work" is clicked.
work.php is loaded into the content-section of index.php
url now: "www.example.com/work
Additionally if the user types www.example.com/work in the address bar index.php should load work.php without a link being clicked.
A good example to understand my issue with the url in the address bar is facebook. Hope I could clarify my problem so somebody is able to help me ;-)
You can only change the hashtag of a URL without refreshing the page (making another request).
So when a navigation link is clicked you could change "www.example.com" to "www.example.com/#work" but you can't change it to "www.example.com/work" without reloading the page.
A hashtag can get set with javascript using window.location.hash
window.location.hash = "work";
If you are looking to avoid hashtags, you can use the HTML5 history API. This allows you to have the / in your pages using the history.pushState() and history.replaceState() method.
There is also this plugin that you may find useful.
I got a situation here. I have a main page and a subpage. The subpage does have an iframe container and there are two pages test1.htm and test2.htm that are loaded into that iframe when your current page is "subpage.htm".
However, what I want to to, is to be able to click on a link on my main page and it opens up the subpage and automatically loads a predefined page, lets say test1.htm into the iframe.
I got the function to load a page into an iframe and I though by using JavaScript and some code this was possible. Unfortunately, I couldn't figure out a way to do this.
function link {
url = '../subpage.htm';
document.target = url;
loadintoiframe(myiframe,test1.htm);
}
I got the function loadintoiframe, it needs the name of the iframe and the page to load.
When I call the function link() as a href link on the main page, it does load the subpage, but it does not load the iframe correctly.
Maybe someone can help me out?
Why not just put
Link
And avoid the JavaScript at all?
So this does not work.
I tried to go for a JavaScript Method that just does a href basically and then calls the method that loads my special page into that iframe on the href site.
That did not work, so anyone else got a clue how I can href a different .htm site and simultaniously tell that site to load a certain page into the iframe?
Best regards,
Alex
I have a page that pulls up information based on an ID from the url using php get. It does this in an iframe. So there is an iframe on the main page that shows all the content, if a user wants a link, they click a link to a page, which is targeted to that iframe. So if a user wants to see an individual post, the iframe is directed to a page that pulls the id from the link.
href="location.php/?id=2" target="mainframe"
My question is, I want someone to be able to click a link to my website from somewhere else, and be able to see just that post, I want to do this without having to create another page, so if there is a way to make a http://www link navigate to my page, and then tell the iframe what to do, that would be awesome. Thanks!
put this at the bottom of your page before the </body>
<script>
document.getElementById('frame_name_goes_here').src = "http://linktoyourpost.html";
</script>
Used php to decide if the Id was present in the url, if it is, direct to the specified id, otherwise, the iframe source is the default page.