Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically insert javascript using Javascript?
    primarykey
    data
    text
    <p>I am trying to dynamically insert a set of script tags with some javascript code in it using javascript. I am basically trying to wrap a file in jwplayer, but the script string is breaking rest of the javascript code in the page. How do I do this correctly?</p> <p>the line causing the problem:</p> <pre><code> $file_link_insert = "&lt;script type='text/javascript'&gt;jwplayer('mediaplayer').setup({flashplayer: 'player.swf', file: '"+$href+"'});&lt;/script&gt;"; </code></pre> <p>Rest of function for ref:</p> <pre><code>$(".file_link").live("click", function(e){ e.preventDefault(); var $href = $(this).attr("rel"); // Dialog $('#filelink').dialog({ autoOpen: true, width: 300, modal: true, buttons: { "Ok": function() { if($("input[name=file_link_text]").val()!=""){ $file_type = fileType($href);//determine if its video file see function below. if($file_type == 'vid'){ $file_link_insert = "&lt;script type='text/javascript'&gt;jwplayer('mediaplayer').setup({flashplayer: 'player.swf', file: '"+$href+"'});&lt;/script&gt;"; // $file_link_insert = " &lt;p&gt;&lt;a href=\""+$href+"\"&gt;"+$("input[name=file_link_text]").val()+"&lt;/a&gt;&lt;/p&gt; "; }else { $file_link_insert = " &lt;p&gt;&lt;a href=\""+$href+"\"&gt;"+$("input[name=file_link_text]").val()+"&lt;/a&gt;&lt;/p&gt; "; } $("#_tinyMCEinit_ifr").contents().find("body").append($file_link_insert); $("#content_editor ul li:first a").click(); $(this).dialog("close"); $("input[name=file_link_text]").val(""); } else { alert("You must enter text label for your link!"); } }, "Cancel": function() { $(this).dialog("close"); } } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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