Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    240

    createRange().pasteHTML da problemi con il tag a href

    Ho la seguente funzione per inserire in un editor di testo html un link

    Ma con IE ho il problema che al link viene aggiunto il percorso locale
    esempio <a href='miolink' target='_self'>
    diventa
    <a href='c:\\cartella\cartella\miolink' target='_self'>

    COME POSSO FARE???????

    Inoltre è possibile prelevare il testo HTML relativo solo al range selezionato???
    se si come se fa???
    codice:
    function insertHTML(rte) {
    	var oRTE;
            tag_apertura = "<a href='miolink' target='_self'>";
    	tag_chiusura = "</a>";
    
    	if (document.all) {
    		oRTE = frames[rte];
    		var rng;
    		var selection = oRTE.document.selection; 
    		if (selection != null) rng = selection.createRange();
    		testo = tag_apertura + rng.text + tag_chiusura;
      	        oRTE.focus();
    		rng.cutHTML;
    		oRTE.document.selection.createRange().pasteHTML(testo);
    
    	} else {
    		oRTE = document.getElementById(rte).contentWindow;
    		var selection = oRTE.getSelection();
    		rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
    
    		testo = tag_apertura + rng + tag_chiusura;
      	        oRTE.focus();
    		oRTE.document.execCommand('insertHTML', false, testo);
    
    
    	}
    }

  2. #2
    Utente di HTML.it L'avatar di byaur
    Registrato dal
    Aug 2004
    Messaggi
    1,061
    ho lo stesso problema anche io...

    e non ho trovato ancora una soluzione...

    qualcuno per caso ha idea di come si risolva??
    PS: naturalmente con firefox, non utilizzando pasteHTML, funziona normalmente...

    vabbè

    VVoVe: VVoVe:
    Chi di noi non vorrebbe
    sollevare il velo sotto cui sta nascosto il
    futuro...
    David Hilbert

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.