简体   繁体   中英

How to open click open link inside a div?

I am building a site that parses a spanish dictionary. If you look up the word HOLA, you will receive the definition, but for other words, you get suggestions, like CASA: http://verbum.xtrweb.com/verbumpost.php?word0=hola&word-1=casa

I wish to: when you click on the suggestions (like CASAR in the example I posted above) to print the result in a div like HOLA. Here is the code I am currently using:

    $words = array('word0','word-1');
    function url_decode($string){
    return urldecode(utf8_decode($string));
    }

    $baseUrl = 'http://lema.rae.es/drae/srv/search?val=';

    $cssReplace = <<<EOT

    <style type="text/css">
    // I changed the style
    </style>
    </head>
EOT;

$resultIndex = 0;

foreach($words as $word) {
if(!isset($_REQUEST[$word]))
    continue;

$contents = file_get_contents($baseUrl . urldecode(utf8_decode($_REQUEST[$word])));

$contents = str_replace('</head>', $cssReplace, $contents);
$contents = preg_replace('/(search?[\d\w]+)/','http://lema.rae.es/drae/srv/search', $contents);


echo "<div style='
      //style
     ", (++$resultIndex) ,"'>", $contents,
        "</div>";
}

I am starting to code, so please be patient, I have also tried with some DOM code a friend suggested but it failed to function.

i think you need to put an iframe inside div. or try to make the click f'n happen in javascript/jquery - make some ajax call, upon click, and show/append the returned results (suggestions) inside the div

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM