mike99c
asked on
Trying to insert a script block in <head> using JQuery
I am trying to use JQuery to insert a script block in the head part of my website but I get an unterminated string error. Here is my code:
When I use the IE debugger it gives the following error:
SCRIPT1015: Unterminated string constant
And it points to the start of </script>.
I tried escaping the single quotes by adding \' but it still does not work.
<script>
$(function() {
$("head").append("<script type='text/javascript'>alert('Hello world');</script>");
});
</script>
When I use the IE debugger it gives the following error:
SCRIPT1015: Unterminated string constant
And it points to the start of </script>.
I tried escaping the single quotes by adding \' but it still does not work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER