script-tag

How to load the script file immediately (dynamically added) before continue?

落爺英雄遲暮 提交于 2019-12-02 08:19:18
问题 I have loaded script file like below code in angular home.component.ts file export class HomeComponent { constructor() { this.loadDynmicallyScript(); } public loadDynmicallyScript() { var script = document.createElement('script'); script.src = "../node_modules/xxxxxx/i18n/xx.min.js"; script.async =false; document.head.appendChild(script); } But this file gets loaded after components created and later. So, in this case, it makes no use of this file. I want to load this file once I appended in

double hyphen in script makes firefox render strangely

随声附和 提交于 2019-12-02 07:11:42
<!-- <script type="text/javascript">/*<![CDATA[*/ c-- ;//]]></script> --> When I have the above line in the <head> section of a plain html page, Firefox 3.5.5 renders the trailing --> as text. If I change c-- to c- it doesn't. Any ideas what's going on here? I getting an artifact on my pages with this due to a very large script that's been crunched. I can change the statement to c-=1 and avoid the problem for now but.... I'd like to know what bit/byte is biting my a$$. This is due to Firefox implementing SGML (on which HTML was based) comments strictly. This will only occur when the document

How to load the script file immediately (dynamically added) before continue?

笑着哭i 提交于 2019-12-02 03:42:42
I have loaded script file like below code in angular home.component.ts file export class HomeComponent { constructor() { this.loadDynmicallyScript(); } public loadDynmicallyScript() { var script = document.createElement('script'); script.src = "../node_modules/xxxxxx/i18n/xx.min.js"; script.async =false; document.head.appendChild(script); } But this file gets loaded after components created and later. So, in this case, it makes no use of this file. I want to load this file once I appended in documents. How to achieve this? You can return a promise to chain calls export class HomeComponent {

How to invoke a javascript function (generated from typescript) trapped within “System.register()” module while using Google protobuf?

心不动则不痛 提交于 2019-12-01 09:09:46
Update : It seems that, the problem is coming due to protobuf. I am fine with other solution as well, which help me to fix the Google protobuf issues. This problem boils down to: How to integrate Google protobuf with Typescript/Javascript for the browser? I am retaining below question for the future purpose. We have moved our application from Javascript to Typescript for obvious advantages of OOP etc.. Earlier invoking a direct javascript function from Html was as straight forward as: <script>window.MyFunction()</script> Now with Typescript, all the files are combined into a single

Why is script.onload not working in a Chrome userscript?

血红的双手。 提交于 2019-12-01 05:54:29
I want to load another script file, in a site, using a userscript. But, the js.onload event doesn't work correctly. The userscript file: // ==UserScript== // @name Code highlight // @description Test // @include http://localhost/* // @version 1.0 // ==/UserScript== var js = document.createElement('script'); js.src = "http://localhost/test/js/load.js"; document.getElementsByTagName("head")[0].appendChild(js); js.onload = function(){ console.log(A) } the load.js file: var A = { name:'aa' } In Chrome, the console outputs "undefined", but the load.js has loaded completely. I tested it in Firefox,

Why is script.onload not working in a Chrome userscript?

帅比萌擦擦* 提交于 2019-12-01 03:35:56
问题 I want to load another script file, in a site, using a userscript. But, the js.onload event doesn't work correctly. The userscript file: // ==UserScript== // @name Code highlight // @description Test // @include http://localhost/* // @version 1.0 // ==/UserScript== var js = document.createElement('script'); js.src = "http://localhost/test/js/load.js"; document.getElementsByTagName("head")[0].appendChild(js); js.onload = function(){ console.log(A) } the load.js file: var A = { name:'aa' } In

How can I tell whether a JavaScript file has already been included in an ASP.NET page?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 18:22:45
I have an ASP.NET user control (.ascx file). In this user control I want to use a .js file. So I include <script src="file.js" type"text/javascript"></script> on the page. However, sometimes I use this user control in a webpage where this same script has already been loaded. How can I add a <script /> declaration that will render on the page only if the page doesn't already contain another <script /> tag for the same script? As you are using asp.net, it makes sense to do the check server-side as that will be where you choose to add the reference to the javascript file. From your .ascx file you

html script tag not using type javascript <script type=“text/html”>?

て烟熏妆下的殇ゞ 提交于 2019-11-30 11:34:51
I was checking out the source on an html page and came across this <script id="searchItemTemplate" type="text/html"> <# var rows = Math.floor((Model.RecordsPerPage - 1) / 3 + 1); for (var i = 0; i < rows; ++i){ var startIdx = i * 3; var endIdx = startIdx + 3; #> //etc .... </script> I have never seen this before. What is script type="text/html" . I don't know if it makes a difference but this was on a .aspx page. Is this some sort of place holder to be parsed and eval() later? Does anyone know what this is? Can someone who has used this method explain the benefits? Script elements that have an

“Unterminated template literal” syntax error when literal contains script tag [duplicate]

纵然是瞬间 提交于 2019-11-30 10:57:14
This question already has an answer here: Why split the <script> tag when writing it with document.write()? 5 answers I'm using ES6 template literals to construct some HTML in strings, and so far it has been working fine. However, as soon as I try to put the literal text </script> in my string the browser throws up and throws the syntax error: SyntaxError: Unterminated template literal Here is a simple JavaScript sample which throws the error: var str=` <script> </script> ` var pre = document.createElement('pre') pre.textContent = str document.body.appendChild(pre) See the above code in JS

How can I tell whether a JavaScript file has already been included in an ASP.NET page?

爱⌒轻易说出口 提交于 2019-11-30 01:27:05
问题 I have an ASP.NET user control (.ascx file). In this user control I want to use a .js file. So I include <script src="file.js" type"text/javascript"></script> on the page. However, sometimes I use this user control in a webpage where this same script has already been loaded. How can I add a <script /> declaration that will render on the page only if the page doesn't already contain another <script /> tag for the same script? 回答1: As you are using asp.net, it makes sense to do the check server