2013-03-26 61 views
-1

我在嘗試在以前的div中打開超鏈接時出現問題,這是由PHP中的ECHO生成的。我的網站的目的是輸出單詞的定義,每個單詞在一個單獨的div。有些詞有兩個或更多的接受建議*參見這裏的現場演示... http://verbum.xtrweb.com/verbumpost.php?word=casa&word0=hola *。點擊任何一個接受將打開定義而不更改風格在新標籤上。我需要替換這個新選項卡的正常格如HOLA中的示例在前一個DIV中打開一個超鏈接

謝謝!該代碼,以幫助您也許......

<?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>"; 
    } 
     ?> 
+0

我很努力去理解你的問題,但是如果你想在不重新加載新頁面的情況下替換DIV的內容,你將需要使用AJAX和Javascript。 – rjmunro 2013-03-26 11:33:46

+0

@rjmunro如果你點擊我包含的鏈接,然後點擊CASA或CASAR,你在一張新標籤中看到的定義,我需要它在一個DIV中就像HOLA一樣...... – 2013-03-26 11:37:43

回答

1

如果要加載的DOM元素內頁,你需要將其加載到一個IFRAME(或幀)不是一個div。 Div元素不能成爲超鏈接或表單的目標。

相關問題