Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems outputting Javascript from WebBroker application
    primarykey
    data
    text
    <p>I have a fairly simple web app built with Delphi (2009) Web Broker. I am trying (and failing) to output Javascript to the page.</p> <p>The javascript I need to output is in the body of the page in a <code>&lt;form&gt;</code> tag, and is as follows:</p> <pre><code>&lt;script&gt;DateInput('mydatefield', true, 'DD-MM-YYYY');&lt;/script&gt; </code></pre> <p>This javascript should create a nice date input control (tested ok in a hand-crafted HTML page). The code in my Delphi app this is:</p> <pre><code>Response.Content := Response.Content + '&lt;script&gt;DateInput(''mydatefield'', true, ''DD-MM-YYYY'');&lt;/script&gt;'; </code></pre> <p>The <em>Script</em> tags are being removed from the final output. </p> <p>As a test I added an HTML button with an <code>onClick</code> event set as follows:</p> <pre><code>Response.Content := Response.Content + '&lt;input type="button" onClick="alert(''Hello World'')" Value="Hello World"/&gt;'; </code></pre> <p>and when the source of the page is inspected </p> <pre><code>alert(''Hello World'') </code></pre> <p>had become </p> <pre><code>alert(&amp;#39;Hello World&amp;#39;) </code></pre> <p>I wondered if this translation of the single quote from ' into <code>&amp;#39</code>; might be causing my earlier script tag to be removed?</p> <p>Any help/pointers appreciated, thanks.</p> <p><em>*</em> EDIT</p> <p>I should point out that the Alert popup does work even with the <code>&amp;#39;</code> characters.</p> <p><em>*</em> EDIT</p> <p>I have tried to use JQuery scripts like $(document).ready( function() { etc }); and it's working, so I guess the problem is not with WebBroker output. Thanks to all who took time to read/think. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload