Ir para conteúdo
Fórum Script Brasil
  • 0

Rotina com problema


Giovanicaf

Pergunta

Amigos estou precisando melhorar esta rotina de marca-texto e estou com alguns problemas:

O texto só é marcado na segunda vez que o botão é clicado por conta do designMode.

O usuário não poderia alterar a página, nem texto, nem figura, nem tabela. da mesma forma que com o designMode false.

Isso poderia ser resolvido se eu ligasse o designMode editasse e desliga-se mas quando ele é invocado faz refresh na página e só funciona da segunda vez quando o designMode está desligado.

Obs: A rotina funciona da seguinte maneira você marca o texto e clica no botão, mas por conta do problema só está funcionando da segunda vez.

No ie funcionou colocando o document.designMode para "Off" mas no firefox não funciona!!!

********* Arquivo index.asp *******************

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();

function marcador( color )
{
    try {
                   
        var frmObj = window.document.getElementById('frmCentro').contentWindow;
       

        frmObj.document.designMode = "On";


//        frmObj.document.body.Design
       
        if (browser.isIE)/* && (browser.version < 7)*/
        {
          frmObj.document.execCommand('backcolor', false, color);
        }
        else
        {
          frmObj.document.execCommand('readonly', false, false);
          frmObj.document.execCommand('hilitecolor', false, color);
          //frmObj.document.designMode = "Off";
          //frmObj.document.setDesignMode = false;         
        }

    }  catch (e) {
      alert("Não é suportado por este browser.");
    }
}
</script>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><img src="../img/Selecionar.gif" width="35" height="35" onclick="marcador( '#FFFF99' );" /></td>
  </tr>
</table>

<iframe id="frmCentro" name="frmCentro" width="600px" height="400px" align="top" frameborder="1" src="teste.asp" scrolling="auto"></iframe>
</body>
</html>
********* Arquivo teste.asp *******************
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table width="100%" border="1" cellspacing="2" cellpadding="2">
  <tr>
    <td>asdasd</td>
  </tr>
  <tr>
    <td>asdasd</td>
  </tr>
</table>
<p>sssss TEste</p>
</body>
</html>

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...