在之前的DIV中打开超链接

时间:2013-03-26 11:29:37

标签: php javascript html hyperlink

我在尝试打开前一个div中的超链接时遇到问题,该超链接由php中的ECHO生成。我的网站的目的是输出单词的定义,每个单词在一个单独的div中。有些单词有2个或更多的建议*请参见此处进行现场演示... http://verbum.xtrweb.com/verbumpost.php?word=casa&word0=hola *。单击任何一个接受将在新选项卡上打开定义而不更改样式。我需要替换正常div 的新选项卡,如示例中的HOLA

谢谢!帮助你的代码......

<?php
    $words = array('word','word0','word1','word2','word3','word4','word5','word6','word7','word7','word9','word10','word11','word12','word13','word14','word15');
    function url_decode($string){
    return urldecode(utf8_decode($string));
    }


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

    // string to replace in the head.
    $cssReplace = <<<EOT

    <style type="text/css">
    //style

    </style>
    </head>
    EOT;


    $spanRemove = '<span class="f"><b>.</b></span>';


    $resultIndex = 0;


    foreach($words as $word) {

    if(!isset($_REQUEST[$word]))
    continue;

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


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

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

1 个答案:

答案 0 :(得分:1)

如果要在dom元素中加载页面,则需要将其加载到iframe(或任何框架)而不是div中。 Div元素不能是超链接或表单的目标。