Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to include a script with document.write?
    primarykey
    data
    text
    <p>We need to add a script to our web application. It basically adds an corporate menu. </p> <p>so we've received a script to include in the body of our webapp:</p> <pre><code>&lt;!-- BEGIN NAVIGATION --&gt; &lt;script type="text/javascript" src="https://intranet.local/?getCorporateJsMenu"&gt;&lt;/script&gt; &lt;!-- END NAVIGATION --&gt; </code></pre> <p>And the content of <a href="https://intranet.local/?getCorporateJsMenu" rel="nofollow">https://intranet.local/?getCorporateJsMenu</a> basically looks like this:</p> <pre><code>document.write('&lt;script type="text/javascript" src="..."&gt;&lt;/script&gt;'); //.... document.write('&lt;div&gt;'); document.write('&lt;ul&gt;'); //... document.write('&lt;li&gt;&lt;a href="..."&gt;...&lt;/a&gt;&lt;/li&gt;'); //... document.write('&lt;/ul&gt;'); document.write('&lt;/div&gt;'); </code></pre> <p>after having placed the <code>&lt;!--NAVIGATION--&gt;&lt;script...</code> directly into the html body we were experiencing severe page load performance problems.</p> <p>so our idea was to add the menu with JS, when everything has already been loaded with something like this:</p> <pre><code>var script=document.createElement('script'); script.type='text/javascript'; script.src='https://intranet.local/?getCorporateJsMenu'; var domparent=jQuery('#header').get(); domparent[0].appendChild(script); </code></pre> <p><strong>with firebug we see, that the script element has been added to the html and the script has been loaded from the network, but somehow the document.write of the loaded script doesn't get executed?</strong></p> <hr> <p>UPDATE: we cannot modify the contents of <a href="https://intranet.local/?getCorporateJsMenu" rel="nofollow">https://intranet.local/?getCorporateJsMenu</a> since it comes from 3rd party</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.
    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