2015-05-25 99 views
0

我有一個小應用程序。即模仿CMS的功能,改變文本,段落和圖像。刷新已修改的iframe

將被修改的頁面位於一個iframe中,我做了所有修改並保存了這些新的文本和圖像,但是當我「點擊」提交時,我們必須手動刷新頁面看到這些變化。

我不知道該怎麼辦了看到這些變化,而不按F5刷新...

這是IFRAME:

<iframe id="probando" src="<?php echo $url; ?>" name="probando"></iframe> 

PHP代碼:

<?php 
$directorioInicial = "./"; //Especifica el directorio a leer 
$rep = opendir($directorioInicial); //Abrimos el directorio 
echo "<div class='button' id='mostrar'>Mostrar archivos</div>"; 
echo "<div id='acordeon' class='propiedadesCaja'>"; 
echo "<ul>"; 
while ($todosArchivos = readdir($rep)) { 
    if ($todosArchivos != '..' && $todosArchivos != '.' && $todosArchivos != ''  && strpos($todosArchivos, '.html') && !is_dir($todosArchivos)) { 
     echo "<li class='listaPaginas' ><a class='listado' href=" .  $todosArchivos . " target='probando'>" . $todosArchivos . "</a></li>";  
// . $directorioInicial . "/" 
    } 
} 
closedir($rep);  
clearstatcache();  
echo "</ul>"; 
echo "</div>"; 
$url = ""; 
if (isset($_POST['textarea'])) { 
    $url = $_POST['textareaPagina']; 
    $salida = $_POST['textarea']; 
    $archivo = fopen($url, "w+"); 
    fwrite($archivo, $salida); 

    fclose($archivo); 
    clearstatcache(); 
} 
    ?> 

我如何可以刷新頁面?用PHP,JavaScript ...?

jQuery代碼:

$("#probando").contents().find("p,h1,h2,h3,h4,h5,h6,span,ul,li,a").on("click", function (e) { 
          swal({ 
           title: "Nuevo texto", 
           text: "Escribe el texto deseado:", 
           type: "input", 
           showCancelButton: true, 
           closeOnConfirm: false, 
           animation: "slide-from-top", 
           inputPlaceholder: "Nuevo texto"}, 
          function (inputValue) { 
           if (inputValue === false) 
            return false; 
           if (inputValue === "") { 
            swal.showInputError("¡No has escrito nada!"); 
            return false 
           } 
           swal("¡Muy bien!", "Nuevo texto: " + inputValue, "success"); 
           $(e.target).text(inputValue); 
           var contenido = $("#probando").contents().find('html').prop('outerHTML'); 
           $("#contenido").text(contenido); 
          }); 


         }); 
+0

修改?你的意思是修改? – Dendromaniac

+0

哈哈是對不起修改:S – Lewis

+0

沒關係...出現了錯誤。 – Dendromaniac

回答

0

嘗試:當你想內嵌框架重載

document.getElementById('probando').contentWindow.location.reload(true);

調用此。

+0

我嘗試了,但沒有找到:( – Lewis

+0

什麼時候你準備讓iFrame刷新? – Dendromaniac

+0

當我點擊提交 – Lewis