0

How to display div #b(only) from a.php file using iframe?

a.php

<html>
    <head></head>
    <body>
        <div id="a">
            Nice day!
        </div>

        <div id="b">
            Nice night!
        </div>
    </body>
</html>

b.php

<IFRAME width=1200" height="1500" scrolling=no frameborder=0 src="a.php"; marginWidth=0 marginHeight=0></IFRAME>
2
  • 1
    Sorry, I don't quite understand what you're looking to do.. are you looking for the div to contain the iframe, or what? Commented Jun 27, 2012 at 11:08
  • it displays the whole contents of file a.php. I would like to display only #div id="b" Commented Jun 27, 2012 at 11:18

3 Answers 3

1

What is the goal here? Will a.php display different comment based on how it is called?

One option is to add a parameter Id:

if ($_GET['id'] == 'a') {
  //display div#a
} else {
  //display div#b
}

<iframe src="a.php?id=b" />
Sign up to request clarification or add additional context in comments.

Comments

0

Please try something like this.

<IFRAME width=1200" height="1500" scrolling=no frameborder=0 src="/a.php#divid"; marginWidth=0 marginHeight=0></IFRAME>

Comments

0

You can do it with jQuery:

$('#target').load('a.html #b'); // take #b from a.html and put in #target

Comments

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.