www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25

Thread: how to link java script code to a web page such as mail.google.com?

  1. #16
    Join Date
    Feb 2010
    Posts
    184

  2. #17
    Join Date
    Jul 2010
    Posts
    20
    I tried with firebug also sir,its showing the same id "compose_editor area".
    wat to do?

  3. #18
    Join Date
    Feb 2010
    Posts
    184
    Have you tried printing the tags inside the iframe

    Code:
    var testing = document.getElementById("compose_editorArea");
    var doc = testing.contentDocument;
    var textareas = doc.getElementsByTagName("textarea");
    alert(textareas.length);
    Alternatively, maybe contentEditable="true" is being used on the body of the iframe so you can get the text by doing the following:

    Code:
    var testing = document.getElementById("compose_editorArea");
    var doc = testing.contentDocument;
    var text = doc.body.innerHTML
    alert(text);
    Playing around with the above e.g. might not be body and textarea should yield the answer.

  4. #19
    Join Date
    Jul 2010
    Posts
    20
    there is no textarea sir.so v cant get any value for that tag name.

  5. #20
    Join Date
    Feb 2010
    Posts
    184
    Please see the second solution as well about the contentEditable="true".

    Basically my question to you is what is being edited?

    If it isn't a textarea you must work out what it is. Again I believe firebug will help.

    It might help if you could post a screenshot so I can have a look for myself.

  6. #21
    Join Date
    Jul 2010
    Posts
    20
    Sir,This is my code

    // ==UserScript==
    // @name yahootest
    // @namespace yahootast
    // @description yahootest
    // @include http://*.yahoo.*
    // ==/UserScript==

    var scriptElement = document.createElement('script');
    scriptElement.type = 'text/javascript';
    scriptElement.innerHTML ='function checkForvalue() { \
    var testing = document.getElementById("compose_editorArea");\
    var doc =testing.contentDocument; \
    vat text = doc.body.innerHTML; \
    alert(text);}';

    document.getElementsByTagName("head")[0].appendChild(scriptElement);
    window.addButton = function () {
    // Get the location on the page where you want to create the button
    var targetDiv = document.getElementById('navcontainer');

    // Create a div to surround the button
    var newDiv = document.createElement('div');
    newDiv.setAttribute('id', 'SendEN');

    // Create the button and set its attributes
    var inputButton = document.createElement('input');
    inputButton.name = 'SendEN';
    inputButton.type = 'button';
    inputButton.value = 'SendEN';
    inputButton.setAttribute("onclick", "checkForvalue();");


    // Append the button to the div
    newDiv.appendChild(inputButton);
    targetDiv.appendChild(newDiv);








    }
    addButton();




    I m uploading the screen shot of file
    Plz check
    Attached Images Attached Images

  7. #22
    Join Date
    Jul 2010
    Posts
    20
    sir can i get ur mail id?

  8. #23
    Join Date
    Feb 2010
    Posts
    184
    You need to limit the script to those pages with targetDiv. Open Manage User Scripts and specifically add the "Included Pages".

  9. #24
    Join Date
    Jul 2010
    Posts
    20
    Thanks a lot for Helping sir!
    M almost done.I m able to read and write the compose box.But writing is being done explicitly.i want to put this function for encoding.How to do?
    M getting errors..



    function encode(text) { Ref="0123456789abcdefghijklmnopqrstuvwxyz.-~ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    Result=""
    for (Count=0; Count<text.length; Count++) {
    Char=text.substring (Count, Count+1);
    Num=Ref.indexOf (Char);
    EncodeChar=Ref.substring(Num+1, Num+2)
    Result += EncodeChar
    } document.form1.result.value=Result
    }

  10. #25
    Join Date
    Feb 2010
    Posts
    184
    Code:
    var scriptElement = document.createElement('script');
    scriptElement.type = 'text/javascript';
    scriptElement.innerHTML ='function checkForvalue() { \
      var testing = document.getElementById("compose_editorArea");\
      var doc =testing.contentDocument; \
      vat text = doc.body.innerHTML; \
      alert(text);}';
    
    document.getElementsByTagName("head")[0].appendChild(scriptElement);
    seems to work well. you could just append the function code to scriptElement and call it.

    I am not too sure what you want, providing the errors would help. I am assuming you can't access the function.

    P.S. The encode function is poorly written. http://www.w3schools.com/jsref/jsref_obj_string.asp

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles