2013-04-27 107 views
0

我正在構建一個解析西班牙語字典的網站。如果你查到單詞HOLA,你會收到定義,但換句話說,你會得到像CASA這樣的建議:http://verbum.xtrweb.com/verbumpost.php?word0=hola&word-1=casa如何打開點擊裏面的div打開鏈接?

我希望:當你點擊建議(如我在上面發佈的例子中的CASAR )以HOLA格式打印結果。這是我目前使用的代碼:

$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>"; 
} 

我開始代碼,所以請耐心等待,我自己也嘗試了一些DOM代碼的朋友建議,但未能發揮作用。

回答

1

我認爲你需要把一個iframe放在div中。 或嘗試使點擊f'n發生在javascript/jquery - 做一些Ajax調用,點擊後,並顯示/追加返回的結果(建議)在div