0

I need to use the output in the variable $data and put it inside an iframe (or other perhaps) so as to scroll it properly. Please, find the mistake in the following code:

    <?php

    $url = 'http://lema.rae.es/drae/srv/search?id=IwxflJmT9DXX2DMkYs8Z';

    $css = <<<EOT

    <style type="text/css">
     body
       {
       background: #eeeeee;
       }
     .a
       {
        color: green;
       }
    .f
       {
        font-size: 200%;
       }
    .o
       {
        font-size: 80%;
        }
    img
        {
        visibility:hidden;
         }

    </style>
    EOT;

    $data = file_get_contents($url);
    $data = str_replace('</head>', $css.'</head>', $data);
    echo "<iframe id='first' src='$data'
          frameborder='0' 
          width='400px' 
          height='300px' 
          scrolling='yes'
          border-style: none;></iframe>";
    ?>  

The problem is probably on the last lines. Instead of the word's definition to appear inside the iframe, an error shows up, saying the object hasn't been found Thanks! enter image description here

6
  • You haven't told us what the problem is. What doesn't work? Commented Dec 7, 2012 at 4:31
  • instead of the word's definition to appear inside the iframe, an error shows up, saying the object hasn't been found Commented Dec 7, 2012 at 4:35
  • 1
    Please put the explanation of what doesn't work in the body of the question, as well as the exact error message you get, rather than a paraphrase of it. Commented Dec 7, 2012 at 4:36
  • @JuanmaAlonso - try changing the iframe attributes as i have posted in answer and let me know if your problem is solved ! Commented Dec 7, 2012 at 5:01
  • @JuanmaAlonso- and is it necessary to use <<EOT?? Commented Dec 7, 2012 at 5:05

2 Answers 2

3

Change <iframe> to the iframe code given below.:

<?php

$url = 'http://lema.rae.es/drae/srv/search?id=IwxflJmT9DXX2DMkYs8Z';

$css = <<<EOT

<style type="text/css">
 body
   {
   background: #eeeeee;
   }
 .a
   {
    color: green;
   }
.f
   {
    font-size: 200%;
   }
.o
   {
    font-size: 80%;
    }
img
    {
    visibility:hidden;
     }

</style>
EOT;

$data = file_get_contents($url);
$data = str_replace('</head>', $css.'</head>', $data);
/*u have to change src like this. and you need to add style attribute to use border-style: none;
   /* echo "<iframe id='first' src='".$data."'
      frameborder='0' 
      width='400px' 
      height='300px' 
      scrolling='yes'
      style='border-style:none;'></iframe>"; */
//Remove this iframe and simply echo $data
echo '<div style="overflow:scroll;">'.$data.'</div>'; //YOU CAN USE AUTO instead of SCROLL
?>    

The output what i am getting is as below:(i have set height:200px; width:500px;)

enter image description here

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

6 Comments

i copied the code just as you wrote but still it shows up "object not found"
@JuanmaAlonso - its showing me Forbidden error showing that You don't have permission to access /<html><head><link rel="stylesheet" type="text/css" href="/drae/css/I.drae.css+estilosCabDrae.css,Mcc.W_CzH9ApGk.css.pagespeed.cf.w1GLVsE-IR.css"><TITLE>Real Academia Española. Diccionario Usual.</TITLE><style type="text/css"> body { background: on this server.
yes, there is no permission, but there must be a way to put $data into an object or something more editable. If i just leave echo $data , it works, i can change the font and everything, but i would like to put everything together, simply on one object, doesn't have to be an iframe. And, if i link the iframe to $url, it works, but my css changes don't take place....
@JuanmaAlonso - let me know is it what exactly wanted??
@JuanmaAlonso - check the updated code with <div>. Specify width and height as you want
|
2

the src attribute on an <iframe/> element takes a URL, not HTML source....

i'm not entirely sure what you want to do, but perhaps you just need to echo your $data ?

10 Comments

so should be then (...) src='$url' ??
well, that will work, but it will load the original page, without your CSS additions
so how is the complete way, including my CSS additions ??
did you try just echo $data;? you might have a bit to work through, still, but that seems to be what you're after?
@JuanmaAlonso - code is changed. Checkout my answer with the output i am getting.
|

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.