Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7497753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:13:02+00:00 2026-05-29T19:13:02+00:00

I am trying to dynamically insert a set of script tags with some javascript

  • 0

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?

the line causing the problem:

        $file_link_insert = "<script   type='text/javascript'>jwplayer('mediaplayer').setup({flashplayer: 'player.swf', file: '"+$href+"'});</script>";

Rest of function for ref:

$(".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 = "<script type='text/javascript'>jwplayer('mediaplayer').setup({flashplayer: 'player.swf', file: '"+$href+"'});</script>";

                                  // $file_link_insert = " <p><a href=\""+$href+"\">"+$("input[name=file_link_text]").val()+"</a></p> ";

                                }else { $file_link_insert = " <p><a href=\""+$href+"\">"+$("input[name=file_link_text]").val()+"</a></p> "; }

                                $("#_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"); 
                            }
                        }
                }); 
            });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:13:05+00:00Added an answer on May 29, 2026 at 7:13 pm

    You can’t include </script> within a javascript because the browser will interpret it as the end of the script. Simply break up or escape the string. like this <\/script>

    See Why split the <script> tag when writing it with document.write()?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to dynamically insert images and texts using javascript, html and css. To
Using jQuery v1.6.4, I'm trying dynamically format some objects. Here is my code: <html>
I'm trying to insert reCaptcha code into my page from jQuery, but it doesn't
I'm using Prototype and trying to dynamically access a variable in a loop. Code
I normally work in Objective-C, but am now trying to integrate some C code
I am trying to create a simplified code to insert images dynamically into a
I'm trying to pass a dynamically created id from a form to JavaScript. <script
Trying to play a sound via javascript and want to change it dynamically using
I am trying to insert into mysql database dynamically. But I always see only
I'm trying to dynamically generate a csv file with some cells that will contain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.