Einzelnen Beitrag anzeigen

gee21

Registriert seit: 3. Jan 2013
199 Beiträge
 
Delphi 10.4 Sydney
 
#1

Webbrowser OleObject - Felder füllen

  Alt 9. Apr 2013, 21:59
Hallo
Weiss jemand von euch warum ich diese 2 Felder nicht ausfüllen kann? Ist das nicht HTML? Oder mache ich mal wieder etwas falsch?

Feld1
Code:
<textarea id="message" name="message" style="width: 100%; overflow=auto;" tabindex="2" onkeypress="sms_message_change(this.form)"
Feld2:
Code:
        <textarea id="recipient" name="recipient" class="wickEnabled" style="width: 100%;" tabindex="1" onclick="hideErrorBlock();" onblur="countRecipients()" rows="2">
ich versuche es so auszufüllen:
webbrowser1.oleobject.document.forms.item(1).elements.item('message').value := memo1.text; (Item0-5 hab ich mal durchprobiert da ich nicht genau wusste wo die Felder genau liegen)

(Ganzer Homepage Code)
Delphi-Quellcode:
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript" />



<script type="text/javascript">
<!--

function convertRecipient(recipient) {

   //remove all non digit numbers but not +
   recipient = recipient.replace(/[^\d|^\+]+/g, "");
   
   if (recipient.length >= 3) {
      //IF first char=0 and 2nd not 0 THEN replace 0 by +41
      if (recipient.match("^0[^0]\d+")) {
         recipient = recipient.replace("^0", "+41");
      }

      
      //IF first and 2nd char=0 THEN replace 00 by +
      if (recipient.match("^00\d+")) {
         recipient = recipient.replace("^00", "+");
      }

   }

   return recipient;
}

function countRecipients(){

   var tmprecipients = document.getElementById('recipient').value
   var arraySpitter = tmprecipients.split(",");
   contactCounter= arraySpitter.length;
   if(contactCounter>10){
      document.getElementById('recipientsWarningTR').style.display = '';
   }

   else{
      document.getElementById('recipientsWarningTR').style.display = 'none';
   }

}

function addRecipient(recipientMsisdn, recipientName) {


   formatedRecipient= recipientName+" <"+convertRecipient(recipientMsisdn)+">";
   
   if(document.getElementById('recipient').value.length==0){
      document.getElementById('recipient').value=formatedRecipient;
   }

   else{
      document.getElementById('recipient').value=document.getElementById('recipient').value+", "+formatedRecipient;
   }


   countRecipients();
}

//-->
</script>

<link rel="stylesheet" href="/mip/ext/css/content.css" type="text/css" media="screen,projection" charset="utf-8" />
<link rel="stylesheet" href="/mip/ext/css/general.css" type="text/css" media="all" title="no title" charset="utf-8" />
<link rel="stylesheet" href="/mip/ext/css/screen.css" type="text/css" media="screen,projection" charset="utf-8" />
<link rel="stylesheet" href="/mip/ext/css/header.css" type="text/css" media="screen,projection" charset="utf-8" />
<link rel="stylesheet" href="/mip/ext/css/images.css" type="text/css" media="all" charset="utf-8" />
<link rel="shortcut icon" href="/mip/ext/img/favicon.ico" type="image/gif" media="all" />
<link rel="icon" href="/mip/ext/img/favicon.ico" type="image/gif" media="all" />
<!--[if IE]>
  <link rel="stylesheet" href="/mip/ext/css/screen_ie.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
<!--[if lt IE 7]>
    <link rel="stylesheet" href="/mip/ext/css/screen_ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
<!--[if lt IE 6]>
    <link rel="stylesheet" href="/mip/ext/css/screen_ltie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->

<STYLE TYPE="text/css">
<!--
BODY {margin: 0;}
INPUT {border: 1px solid #C1B2B4;}
TEXTAREA {border: 1px solid #C1B2B4;}
textarea.error {
  background-color:#FCE5F1;
  color:black;
}

.radio_b {
  border: none !important;
  vertical-align: middle !important;
  padding-left: 10px;
  padding-right: 2px 2px 2px 0px;
}

.attachment_b {border: 1px solid #C1B2B4 !important;}
.attachment_b_opera {border: none !important;}

.accordion h2 {
  background-color:#E0CED0;
  padding:0pt;
  margin:0pt;
  cursor: pointer;
}

.accordion h2 span {
  padding:0px;
  margin:0pt;
}

.accordion h2 span img {
  float:right;
  margin:0.4em 0.4em 0pt 0pt;
  padding-right:0.4em;
}

.contacts div {
  line-height:2.0em;
  padding-left:0.4em;
}

.header {
  padding-bottom:0.5em;
  padding-top:0.5em;
}

.contact_item div {
  display: inline;
  cursor: pointer;
}

.button div {
  display:table-cell;
}

 
* html .button {
  display:inline-block;
}


.pg-normal {
   font-weight: normal;
}

 
.pg-selected {
   font-weight: bold;
}

-->
</STYLE>

<title>SMS-/MMS-Sender</title>

   
   <script type="text/javascript" language="JavaScript" src="/mip/ext/js/paging.js"></script>
   
   
   <script type="text/javascript" language="JavaScript" src="/mip/ext/js/motionpack.js"></script>
   
   
   
   <link rel="stylesheet" href="/mip/ext/css/wick.css" type="text/css" media="all" title="no title" charset="utf-8" />
   
   
   
   
   
   
   
   
   
      <script type="text/javascript" language="JavaScript">
         collection = ['""'];
      </script>
   
   
   
   <script type="text/javascript" language="JavaScript">
      contactCounter=0;
   </script>
   
   <script type="text/javascript" language="JavaScript" src="/mip/ext/js/wick.js"></script>
   
   
   
      <script type="text/javascript" language="JavaScript">
      //<!--
       function checkForm() {
          answer = true;

           if ( document.getElementById('mmsRB').checked) {
            document.getElementById('mmsAttachmentFileName').value = document.getElementById('mmsAttachment').value;
         }

       
          if (siw && siw.selectingSomething)
               answer = false;
          return answer;
       }
      //-->
   </script>
   

   
   
   
   
   <script type="text/javascript" language="JavaScript" src="/mip/ext/js/cookieTools.js"></script>


</head>

<body onload="onBodyLoadFn()" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">

   
   

  
  <p>
    
      <span id="errorBlock" class="error">
        
          <!-- SMS limit reached warning -->
       <div id="smsWarningTR" style="display:none;">
           Die maximale Nachrichtenlänge wurde erreicht.
       </div>
       </span>
     
  </p>

    <div id="recipientsWarningTR" class="error" style="display:none;">
        Es können maximal 10 Empfänger pro Nachricht ausgewählt werden.
    </div>

  

  

  <table border="0" width="100%" style="margin: 0pt">
    <!-- set up proportions -->
    <tr>
      <td width="30%"></td>
      <td width="50%"></td>
      <td></td>
    </tr>

    <!-- Here begins the form -->
    <form id="smsMmsSenderForm" method="post" action="/mip/dyn/login/smsMeinKonto?lang=de" enctype="multipart/form-data" onsubmit="return checkForm()">

    <!-- Sender -->
    <tr>
      <td>
        Absender
      </td>
      <td colspan="2">
         000000000
      </td>
    </tr>

    <!-- Recipient input text + message length counter -->
    <tr>
      <td>
        Empfänger
      </td>
      <td>
        <textarea id="recipient" name="recipient" class="wickEnabled" style="width: 100%;" tabindex="1" onclick="hideErrorBlock();" onblur="countRecipients()" rows="2"></textarea>
      </td>
      <td style="text-align: right">
        <div style="float:right;"><input style="width: 45px;" type="text" name="charsLeft" readonly="readonly" maxlength="10" tabindex="-1" value="160" /></div>
      </td>
    </tr>

    <!-- SMS / MMS Switch -->
    <tr>
      <td>
      &nbsp;
      </td>
      <td style="padding-left: 0px;" colspan="2">
      <div style="vertical-align: middle; padding: 4px 2px 0px 0px;">
           <input id="smsRB" name="type" class="radio_b" tabindex="-1" onclick="hideErrorBlock(); switchToSmsView(this.form);" type="radio" value="sms" checked="checked"/>SMS
           <input id="mmsRB" name="type" class="radio_b" tabindex="-1" onclick="hideErrorBlock(); switchToMmsView(this.form);" type="radio" value="mms"/>MMS
      </div>
      </td>
    </tr>

    <!-- Message textarea -->
      <tr>
        <td>
          Nachricht
        </td>
        <td colspan="2">
          <textarea id="message" name="message" style="width: 100%; overflow=auto;" tabindex="2" onkeypress="sms_message_change(this.form)" onkeyup="sms_message_change(this.form)" rows="4" cols="40"></textarea>
        </td>
      </tr>

    <!-- MMS Attachment -->
    <tr id="mmsAttachmentTR" style="display:none;">
      <td>
        Bild hinzufügen:
      </td>
      <td colspan="2">
        <input type="file" class="attachment_b" id="mmsAttachment" name="mmsAttachment" size="10" accept="image/*" tabindex="3">
        <input id="mmsAttachmentFileName" name="mmsAttachmentFileName" type="hidden" value=""/>
      </td>
    </tr>

    <!-- SMS counters -->
      <tr>
        <td>

        </td>

        <!-- Show [Send] button if it is possible -->
        <td colspan="2">
            
              <div class="submit">
                <button type="submit" value="send" name="send" tabindex="4">Senden</button>
                <input type="hidden" name="task" value="send"/>
                <input type="hidden" name="currentMsisdn" value="000000000000"/>
              </div>
            
        </td>
      </tr>
    </form>

    <!-- Show [Buy] button if it is possible -->
    <tr>
       <td>
          Guthaben
       </td>
      <td>
        <form method="post" action="">
            
        </form>
      </td>
      <td>
          Gratis 49
          Bezahlt 0
      </td>
    </tr>
    <tr>
       <td>
          Postausgang
       </td>
       <td>
          <div class="submit">
               <button type="submit" name="outbox" onclick="openOutboxWindow('/mip/dyn/login/outboxMeinKonto')">Gesendete Nachrichten</button>
          </div>
       </td>
    </tr>
  </table>

  <div class="accordion">
    <h2 class="header first-child" onClick="toggle('contacts','slide_toggle','/mip/ext/img/bus_plus_n.gif','/mip/ext/img/bus_minus_n.gif');">
      <span><img src="/mip/ext/img/bus_plus_n.gif" id="slide_toggle"/></span>
      <span style="padding-left:0.4em;">Adressbuch</span>
    </h2>

    <div class="contacts" id="contacts" style="overflow:hidden;">
        <div class="header">
          <form id="SMSCommand" method="post" action="/mip/dyn/login/smsMeinKonto?lang=de">
          
        
          <div style="float:left;width:70%;padding-left:0.3em;">
            <input id="contactName" name="contactName" class="normal" style="width:49%" tabindex="5" onfocus="if(this.value=='Hans Muster') {this.value='';this.style.color='#000000';}" onblur="if(this.value=='') {this.value='Hans Muster';this.style.color='#afafaf';}" type="text" value="" maxlength="50"/>
            <input id="contactMsisdn" name="contactMsisdn" class="normal" style="width:49%" tabindex="6" onfocus="if(this.value=='+41 76 123 45 67') {this.value='';this.style.color='#000000';}" onblur="if(this.value=='') {this.value='+41 76 123 45 67';this.style.color='#afafaf';}" type="text" value="" maxlength="50"/>
         <input id="editID" name="editID" type="hidden" value=""/>
            <script type="text/javascript">
            //<!--
            if(document.getElementById('contactName').className!="error") {
                document.getElementById('contactName').value = 'Hans Muster';
                document.getElementById('contactName').style.color = '#afafaf';
                document.getElementById('editID').value=''; 
            }

            if(document.getElementById('contactMsisdn').className!="error") {
                document.getElementById('contactMsisdn').value = '+41 76 123 45 67';
                document.getElementById('contactMsisdn').style.color = '#afafaf';
                document.getElementById('editID').value='';
            }

            //-->
            </script>
          </div>
          <div class="button">
            <div class="submit">
              <button type="submit" onclick="if(document.getElementById('contactName').value=='Hans Muster'){document.getElementById('contactName').value=''};if(document.getElementById('contactMsisdn').value=='+41 76 123 45 67'){document.getElementById('contactMsisdn').value=''};this.style.color='#000000';"
                value="addContact" name="add">hinzufügen</button>
              <input type="hidden" name="task" value="addContact"/>
              <input type="hidden" name="currentMsisdn" value="0765790054"/>
            </div>
          </div>
          </form>
        </div>
        
        <div id="pageNavPosition" class="pagenavigation" style="padding-left:1.2em;display:none;"></div>
        
        
    </div>
  </div>

  
  <script type="text/javascript">
  //<!--
    function editContact(id,msisdn,name){
       document.getElementById('contactName').value=name;
       document.getElementById('editID').value=id; 
       document.getElementById('contactName').style.color='#000000';
       document.getElementById('contactMsisdn').value=msisdn;
       document.getElementById('contactMsisdn').style.color='#000000'; 

     }

  
  
   var cookieName = 'mip_msg_dispContacts';
   
   var x = readCookie(cookieName)
   if (x == "1") {
      document.getElementById('contacts').style.display = "block";
      document.getElementById('slide_toggle').src = "/mip/ext/img/bus_minus_n.gif";
   }
 else if (x == "0") {
      document.getElementById('contacts').style.display = "none";
      document.getElementById('slide_toggle').src = "/mip/ext/img/bus_plus_n.gif";
   }
 else if (x == null) {
      //default setting
      document.getElementById('contacts').style.display = "none";
      document.getElementById('slide_toggle').src = "/mip/ext/img/bus_plus_n.gif";
      //create cookie
      createCookie(cookieName,'0',1000);
   }

   
   function toggle(objname,controller,img_open,img_close){
   
      if(document.getElementById(objname).style.display == "none") {
        //open
        document.getElementById(controller).src = img_close;
        slidedown(objname);
        createCookie(cookieName,'1',1000);
      }
 else if (document.getElementById(objname).style.display == "block") {
        //close
        document.getElementById(controller).src = img_open;
        slideup(objname);
        createCookie(cookieName,'0',1000);
      }
 else {
        return;
      }

      
      _IG_AdjustIFrameHeight();
   }
   
   function onBodyLoadFn() {
      if (window.opera) {
         var box = document.getElementById('mmsAttachment');
         box.className = 'attachment_b_opera';
      }

      
      switchToProperSmsMmsView();
   }
    
   function switchToProperSmsMmsView() {
      var thisform = document.getElementById('smsMmsSenderForm');
      if ( document.getElementById('mmsRB').checked) {
         switchToMmsView(thisform);
      }
 else {
         switchToSmsView(thisform);
      }

   }
      
   function switchToSmsView(thisform) {
      document.getElementById('mmsAttachmentTR').style.display = 'none';
      
      sms_message_change(thisform);
      
      _IG_AdjustIFrameHeight();
   }

   
   function switchToMmsView(thisform){
      document.getElementById('mmsAttachmentTR').style.display = '';

      sms_message_change(thisform);
   
      _IG_AdjustIFrameHeight();
   }

    
   function hideErrorBlock() {
      document.getElementById('errorBlock').style.display = 'none';
   }


    //get contact setting
   contactsPerPage = parseInt(queryString('up_contactsPerPage'));
   
   if (isNaN(contactsPerPage)) {
      contactsPerPage = 10;
   }

   
   var pager = new Pager('contact', contactsPerPage);
   pager.init('pageNavPosition');
   pager.showPageNav('pager', 'pageNavPosition');
   pager.showPage(1);
   
   function queryString(parameter) {
      var loc = location.search.substring(1, location.search.length);
      var param_value = false;
      
      var params = loc.split("&");
      for (i=0; i<params.length;i++) {
          param_name = params[i].substring(0,params[i].indexOf('='));
          if (param_name == parameter) {
              param_value = params[i].substring(params[i].indexOf('=')+1)
          }

      }
      if (param_value) {
          return param_value;
      }
 else {
          return false; //Here determine return if no parameter is found
      }

    }

      function openOutboxWindow (outboxUrl) {
          window.open(outboxUrl, "outbox", "menubar=no,status=no,titlebar=no,width=800,resizable=yes,scrollbars=yes");
      }

   
     function sms_message_change(thisform) {
       
        var maxLength;
        var msg = thisform.message.value;

      var newlineCount = msg.split("\n").length - 1;

      if (navigator.userAgent.indexOf("MSIE") > 0) {
         newlineCount = msg.split("\r\n|\r|\n").length - 1;
      }


      var charcount = msg.length + newlineCount;   
      
        if (document.getElementById('mmsAttachmentTR').style.display == '') {
           maxLength = 3000;
         thisform.charsLeft.value = maxLength - charcount;
         if(charcount > maxLength) {
               thisform.message.value = msg.slice(0, maxLength - newlineCount);
               return;
         }

        } else {
          maxLength = 160;
         var maxSms = 3;
         
         if (charcount > maxLength * maxSms) {
            thisform.message.value = msg.slice(0, (maxLength * maxSms) - newlineCount);   
            document.getElementById('smsWarningTR').style.display = '';
            _IG_AdjustIFrameHeight();
         }
 else {
            document.getElementById('smsWarningTR').style.display = 'none';
         }

         
         numberOfSms = Math.floor((charcount-1) / maxLength) + 1;
         
         if (numberOfSms == 0) {
            thisform.charsLeft.value = maxLength + " / 1";
         }
 else {
            thisform.charsLeft.value = (maxLength * numberOfSms - charcount) + " / " + numberOfSms;
         }

      }
       
        if((navigator.userAgent.indexOf("MSIE") == -1) && (navigator.userAgent.indexOf("Mozilla/4") != -1)) {
            thisform.message.blur();
            thisform.message.focus();
        }

    }
   //-->

      </script>

  
  
</body>
</html>
Robert

Geändert von gee21 ( 9. Apr 2013 um 22:09 Uhr)
  Mit Zitat antworten Zitat