0

i want to have an iframe, which displays the page given as parameter in the url. I'm using ASP.NET MVC4

so I wanna do something like this:

updated it... but still not right i think

 <?php
 if(!isset($_GET['link']){
 $link = $_GET['link'];}
 ?>

<iframe name="inlineframe" src="<?php $link ?>" frameborder="0" scrolling="auto"          width="500" height="180" marginwidth="5" marginheight="5" ></iframe>

but i can't figure out the right code for this. can anyone help?

I also tried echoing php, but that doesnt seem to work for me.

3
  • 1
    Try to use the method $_GET instead of $_POST Commented Jun 19, 2012 at 12:40
  • Agreed with Sergey. However, I do hope you have a good reason to use iframes at all... Because they're pretty terrible. Commented Jun 19, 2012 at 12:42
  • yes pretty good reason, im intern and boss is asking for it :) Commented Jun 19, 2012 at 12:47

2 Answers 2

1

The problem with your code snippet is this:

src="<?php $link ?>"

You're calling the variable, but doing nothing with it

To write the variable in the src attribute, use echo:

src="<?php echo $link ?>"

You should also remove the ! in your if statement

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

 <?php
    $link = '';
    if(isset($_GET['link']){
        $link = $_GET['link'];
    }
 ?>

Also echo your link variable. src="<?php echo $link; ?>"

1 Comment

thanks, i chose the other answer because he responded a little bit faster, but both answers helped :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.