php open dynamic link in new window with iframe - php

Hello I am trying to figure out how to make it so when someone clicks a link on my search results it will open in a new window and in the new window have an iframe that displays the url. I am not sure how to go about doing this. I have
$row['url']
that displays the url for each result to use.
To be more specific I am trying to do what filestube does. I like the feature a lot and would like to use something like it on my site. Here is an example url to show you want I mean http://www.filestube.com/5a4c10249bd9fce003e9/go.html
when the link is clicked on filestube it will open a page like this. I have seen lots of sites do this but filestube is what pops in my head right now. Can anyone provide me with a code example or try to explain how to do this? thanks.

You need to redirect to a URL inside of your application, example my_url.php and post to it in parameters the URL you want to show. Than in that script, load an iFrame with that URL.
Example of my_url.php?url=http://www.google.ca:
<div>You Header</div>
<iframe src="<?php $_GET['url']"></iframe>
<div>Your Footer</div>

The link should point to another PHP page. Something like this.
http://www.google.com
In your open-link.php, write your iframe code.
<iframe src="<?=$_GET['url']?>"></iframe>

Assuming you have PHP file named external.php
Make that PHP file accept a $_GET parameter.
Pass the URL as a param
Use that URL to point the iframe in that PHP file to whatever URL is passed

Related

a href refers to site itself + link instead of the link itself

In Codeigniter, I have a database containing a link of a site.
Each item(event) has a link to the event page.
Site
But instead of going to the desired site, it just adds the link to the existing url like this: http://web.site.local/index.php/evenementen/www.referedsite.com
when checking the html code it shows the following:
Site
Does anyone know how to make it go to www.referedsite.com instead of making it add this to the existing link?
You need to put HTTP://
Site
In codeignitor you can use
echo anchor('', 'Site');
// Prints: Site
Read CI Anchor
try
Site

Iframe URL - PHP or Javascript?

I'm trying to build a custom top toolbar which an iframe below it.
Something similar to this:
http://themes.goodlayers.com/?theme=greenearth
I plan one using it on a blog, so i will be making posts linking to other sites. My question is what do i need to make a custom url function that so i just add it in front of the other site's url so that it shows up in an iframe.
For example:
I want to link to google in an iframe with my top toolbar above.
Is there a script that allows me to use a url like this:
http://www.mywebsite.com/frame.php?http://www.google.com/
Thanks for your time!
Iframes are always bad. Don't do it.
That said, with PHP, you can do this:
<iframe src="<? echo $_SERVER['QUERY_STRING'] ?>" />
You can also do something like mywebsite.com?url=google.com, and use $_GET['url'] instead.
Eg url: http://mywebsite.com/index.php?iframe=http://www.google.ro
PHP:
<?php
if ($_GET['iframe']) {
echo"<iframe src='".$_GET['iframe']"' width='200px' height='150px'>";
} ?>
I hope this will help you!

Can I modify anchor tag href in htaccess?

Not sure if this is possible but wanted to know if htaccess has a trick...
Say I have anchor tag href like this -
Click here
I have changed the URL structure using mod_rewrite but wanted to know if i can hide the actual URL in href using htaccess.
i.e when a user hover over the anchor tag, the browser displays http://example.com/index.php?id=12345 at the bottom. All I want the browser to display is http://example.com/index/12345 without changing it manually on all my pages.
Thanks for the help !
Why don't you change the link to the following?
Click here
As you can change the .htaccess I expect that you own or adminstrate this domain. So it should be possible.
If the links are generated by PHP code, then I suggest you to implement and use a translation function like:
function beautify($ugly) {
// your logic comes here
return $nice; // ;)
}
... and wrap it around the existing code that currently outputs the urls. This would have two advantages:
It's easy and more failsafe to migrate to the new url scheme
From now on you have control over all url related code using a single function
I agree, htaccess can't help you. I guess you'll have to change them manually.
I wish I could be of more help
No. htaccess is for processing input to the web server, not data sent back from the server.
If you use jQuery you could have it rewrite the href when the page loads using something like this.
$(function(){
$("a").each(function() {
this.href = 'some_new_url that you made based on the one in this.href';
});
});

Issue with formulating a url php / html

I am trying to formulate a link to another page in my directory. It can either be done in the php code or the html. However for some strange reason, and only on this page, everytime i generate a url to a new page, the url generated is the page i am on + the url i want to go to.
For example, if i am on mysite.php and formulate a link to go to purchase.php then the generated url is mysite.php/purchase.php
Does anyone know why this might be?
<h1>Success</h1>
Link text
<?php
...
...
?>
this is essentially all i have with an echo saying hi! . What happens is, if i am currently on home.php the above url becomes path/home.php/page.php
You should create url for /purchase.php instead of purchase.php.
You can read more about what's the difference in here.

using getHtmlSource in Selenium after following a link on the initial page

I opened a page and am following a couple of links with the click() method.
$this->selenium->open("test.html");
$this->selenium->click("link=testlink1");
$this->selenium->waitForPageToLoad("10000");
$this->selenium->click("link=testlink2");
$this->selenium->getHtmlSource();
Now I want to get the HTML source of the current page that I am on, but getHtmlSource seems to only get the source of the initial page from the open() call.
How do I get the HTML source of the page from 'testlink2'? The last link I followed and the current page I'm on.
Ok, so it appears if you do this, things work.
$link2 = $this->selenium->click("link=testlink2");
$this->selenium->getHtmlSource($link2);
Now, I'm running into a problem that getHtmlSource doesn't seem to returning everything. Looks like it has some sort of buffer limit :(
Also, it doesn't look like this technique will work on links to pages that require authentication. So if you login first, then click on some links, it doesn't work.
getHtmlSource should return the current page's HTML source. Your example might need an additional waitForPageToLoad between clicking the link and getting the page source.

Categories