Iframe URL - PHP or Javascript? - php

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!

Related

I am trying to embed global session variables with url using iframe

I am trying to embed session variables to url that are set by another module in drupal 7.When i try to make an iframe the iframe works but my session variables are not embedded with url.
Any help will be much appreciated.i also checked sessions using devel modules session viewer they are shown there.
Here is the code that i am using in the iframe content type.
<iframe src="http://www.w3schools.com?"$_SESSION['name']""></iframe>
actully im not aware about drupal but i think this will work
<iframe src="http://www.w3schools.com?sname='"<?php echo $_SESSION['name']; ?>"'"></iframe>
please try this
$_SESSION['name'] shoud be
You need to add php code tag for php code.
Always use for dyanmic codde
i am not drupal developer but in this iframe php syntax is not proper. concatenation is missing .
<iframe src="http://www.w3schools.com?"<?php echo $_SESSION['name'];?>""></iframe>
please try this.

Wordpress functions are not working inside iframe in wordpress

I am using an iframe in wordpress, but the page inside iframe not supporting wordpress functions.
the page inside iframe is from the same domain.
Here is what i am trying to do:
I am trying to call a css inside iframe page via wordpress function. Below is how i am using iframe tag :
<iframe id="iframeBox" src="<?php echo get_template_directory_uri();?>/iframe/scoreboard_summary.php" sandbox="" FRAMEBORDER="no" ></iframe>
Here is the css calling tag in my page scoreboard_summary.php :
<link type="text/css" rel="stylesheet" href="<?php echo get_template_directory_uri();?>/style.css">
the function get_template_directory_uri() is not working ?
Please let me know what should i need to do?
Thanks in advance.
iframes are just webpages pulled in and shown in a div. You can't interact with them in that way. PHP has already spit out what was defined by the loops and rules you set. You would want to look into ajax for something like that if you want to talk to the server and bring up new data at an interval, and skip the iframe.
<?php echo 'do this thing' ?> just turns into this thing after the page is loaded. There isn't much to hook into.
If you are just trying to get the stylesheet and apply it to you your page, then I would suggest getting the whole, standard, URL for that stylesheet and skip the template directory uri etc.
Maybe you can explain it better with some code or an example like this one, it's an iframe that refreshes at an interval. Good Luck!
http://jsfiddle.net/sheriffderek/3C9qP/

Trying php to reload page

I am trying to use an image as a button to refresh pages on a website. The footer (a php include) is currently using this code to refresh each page:
<img src="/images/refresh.png">
which of course works. BUT I would like to improve it. Essentially, it would be something like this:
onClick="javascript: window.location.href='abcd.html';"
BUT I need it to work dynamically because I'm using php pages. So I was thinking this would work:
<img src="/images/refresh.png">
But it doesn't work. Any ideas? I'm using <? php $_SERVER['REQUEST_URI'] ?> wrong (obviously), so, any ideas for assistance? Thank you for any help!
Problem noticed is you have a space between <? and php in the following line:
<img src="/images/refresh.png">
Also you want to echo out the value for $_SERVER['REQUEST_URI']. You are just calling $_SERVER['REQUEST_URI']. Also as #NickCoons pointed out when using the echo construct you need to add a semi-colon i.e. echo $_SERVER['REQUEST_URI'];.
Try the following:
<img src="/images/refresh.png">

All links in codeigniter are maintaining old segments - why?

If you link off the homepage it works. So www.domain.com goes to www.domain.com/parent1/mypage.php but then when I link to the next page it keeps the first segment/parent (right word?) so the link becomes www.domain.com/parent1/parent2/anotherpage.php and so on.
After three clicks we have www.domain.com/parent1/parent2/parent3/third.php. Any idea where I did something wrong. This is also affecting images and all images are appearing as if they are in the category www.domain.com/parent1/images/image.jpg - not sure what the parent1 is there.
I hope that made sense. I am really in trouble here. Any help?
You either want to use base_url as Robert has suggested like this:
Post 123
or you can use site_url() like this:
Post 123
or if you can use the anchor() tag like this:
<?php echo anchor("blog/post/123", "Post 123"); ?>
You're (probably) using relative URI's instead of absolute, that's what is messing it up.
When creating links, it's recommended to use base_url function like this:
echo base_url("blog/post/123");
if you're using it inside a HTML template, just add PHP tags:
<?php echo base_url("blog/post/123"); ?>
You can also use it like this:
Post 123

php open dynamic link in new window with iframe

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

Categories