How to embed quote in dynamic IFrame Input element?

Discussion in 'Javascript' started by Csaba2000, Oct 2, 2003.

  1. Csaba2000

    Csaba2000 Guest

    I want to be able to embed a single quote into an INPUT element
    within a dynamically generated IFRAME. The example below
    shows how the IFRAME is generated.

    Challenge: I'd like the alert box to show: Mom said, "Don't"
    instead of the current: Mom said, "Do not".

    The point of the exercise is that I will be passing arbitrary
    strings to the IFRAME and I want to ensure that the final
    string is the same as the original. So I'm interested in dealing
    with all the troublemaker characters.

    Thanks,
    Csaba Gabor from New York

    PS. The point of the alert is to validate that everything
    is copasetic with the IFRAME.



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>IFrame test page</TITLE>
    <META http-equiv=Content-Type
    content="text/html; charset=windows-1252">
    <SCRIPT type="text/javascript">
    function makeIframe() {
    var iframe = document.createElement("IFRAME");
    iframe.src = "javascript:'<HTML><HEAD>";
    iframe.src += "<TITLE>Dynamic IFrame</TITLE>";
    iframe.src += '</HEAD><BODY onLoad="alert(';
    iframe.src += 'document.getElementById(';
    iframe.src += '&quot;myInput&quot;).value)">';
    iframe.src += '<FORM method=get action=dummy.php>';
    iframe.src += "<input type=text id=" + "myInput ";
    iframe.src += 'value="Mom said, &quot;Do not&quot;">';
    iframe.src += "</FORM></BODY></HTML>'"
    document.body.appendChild(iframe);
    }
    </SCRIPT>
    </HEAD><BODY style="margin:5%" onLoad="makeIframe()">
    Main Body
    </BODY>
    </HTML>
     
    Csaba2000, Oct 2, 2003
    #1
    1. Advertising

  2. Csaba2000

    Csaba2000 Guest

    A solution to the specific problem is to replace the
    Do not (8 lines before the </HTML>)
    with
    Don\x5Cx27t

    Csaba
    PS. I've been testing on IE 5.5

    "Csaba2000" <> wrote in message news:bli0gm$...
    > I want to be able to embed a single quote into an INPUT element
    > within a dynamically generated IFRAME. The example below
    > shows how the IFRAME is generated.
    >
    > Challenge: I'd like the alert box to show: Mom said, "Don't"
    > instead of the current: Mom said, "Do not".
    >
    > The point of the exercise is that I will be passing arbitrary
    > strings to the IFRAME and I want to ensure that the final
    > string is the same as the original. So I'm interested in dealing
    > with all the troublemaker characters.
    >
    > Thanks,
    > Csaba Gabor from New York
    >
    > PS. The point of the alert is to validate that everything
    > is copasetic with the IFRAME.
    >
    >
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML><HEAD><TITLE>IFrame test page</TITLE>
    > <META http-equiv=Content-Type
    > content="text/html; charset=windows-1252">
    > <SCRIPT type="text/javascript">
    > function makeIframe() {
    > var iframe = document.createElement("IFRAME");
    > iframe.src = "javascript:'<HTML><HEAD>";
    > iframe.src += "<TITLE>Dynamic IFrame</TITLE>";
    > iframe.src += '</HEAD><BODY onLoad="alert(';
    > iframe.src += 'document.getElementById(';
    > iframe.src += '&quot;myInput&quot;).value)">';
    > iframe.src += '<FORM method=get action=dummy.php>';
    > iframe.src += "<input type=text id=" + "myInput ";
    > iframe.src += 'value="Mom said, &quot;Do not&quot;">';
    > iframe.src += "</FORM></BODY></HTML>'"
    > document.body.appendChild(iframe);
    > }
    > </SCRIPT>
    > </HEAD><BODY style="margin:5%" onLoad="makeIframe()">
    > Main Body
    > </BODY>
    > </HTML>
     
    Csaba2000, Oct 2, 2003
    #2
    1. Advertising

  3. Csaba2000

    W d'Anjos Guest

    Try:

    iframe.src += 'value="Mom said, &quot;Don\'t&quot;">';

    -Wagner
     
    W d'Anjos, Oct 3, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    13,237
  2. Stimp
    Replies:
    2
    Views:
    2,269
    Stimp
    Sep 20, 2006
  3. Eric Layman
    Replies:
    3
    Views:
    629
    Rad [Visual C# MVP]
    Apr 14, 2007
  4. Replies:
    6
    Views:
    441
    Stefan Ram
    Jun 15, 2008
  5. Valery Khamenya
    Replies:
    3
    Views:
    715
Loading...

Share This Page