script-tag

How does HTML tags work inside script tag?

纵然是瞬间 提交于 2019-12-17 15:32:55
问题 For example, view-source at Joel Spolsky's public career profile <script type="text/html" id="stackexchangeanswerswidget"> <h3>Top Answers</h3> <div class="answers"> </div> </script> <script type="text/html" id="topanswer"> <div class="top-answer"> <div class="top-answer-stats">{{= shared.htmlEncode(Score) }}</div> <span class="top-answer-title"><a href="{{=AnswerLink}}">{{= shared.htmlEncode(Title) }}</a></span> <a class="add-answer">add</a> <br class="clear" /> </div> </script> <script type

How to pass parameters to a Script tag?

我是研究僧i 提交于 2019-12-17 03:51:58
问题 I read the tutorial DIY widgets - How to embed your site on another site for XSS Widgets by Dr. Nic. I'm looking for a way to pass parameters to the script tag. For example, to make the following work: <script src="http://path/to/widget.js?param_a=1&param_b=3"></script> Is there a way to do this? Two interesting links: How to embed Javascript widget that depends on jQuery into an unknown environment (Stackoverflow discussion) An article on passing parameters to a script tag 回答1: I apologise

HTML/Javascript: how to access JSON data loaded in a script tag with src set

笑着哭i 提交于 2019-12-17 03:32:23
问题 I have this JSON file I generate in the server I want to make accessible on the client as the page is viewable. Basically what I want to achieve is: I have the following tag declared in my html document: <script id="test" type="application/json" src="http://myresources/stuf.json"> The file referred in its source has JSON data. As I've seen, data has been downloaded, just like it happens with the scripts. Now, how do I access it in Javascript? I've tried accessing the script tag, with and

HTML/Javascript: how to access JSON data loaded in a script tag with src set

你离开我真会死。 提交于 2019-12-17 03:32:14
问题 I have this JSON file I generate in the server I want to make accessible on the client as the page is viewable. Basically what I want to achieve is: I have the following tag declared in my html document: <script id="test" type="application/json" src="http://myresources/stuf.json"> The file referred in its source has JSON data. As I've seen, data has been downloaded, just like it happens with the scripts. Now, how do I access it in Javascript? I've tried accessing the script tag, with and

How to tell if a <script> tag failed to load

我是研究僧i 提交于 2019-12-17 02:27:34
问题 I'm dynamically adding <script> tags to a page's <head> , and I'd like to be able to tell whether the loading failed in some way -- a 404, a script error in the loaded script, whatever. In Firefox, this works: var script_tag = document.createElement('script'); script_tag.setAttribute('type', 'text/javascript'); script_tag.setAttribute('src', 'http://fail.org/nonexistant.js'); script_tag.onerror = function() { alert("Loading failed!"); } document.getElementsByTagName('head')[0].appendChild

How to force a script reload and re-execute?

泄露秘密 提交于 2019-12-17 02:12:11
问题 I have a page that is loading a script from a third party (news feed). The src url for the script is assigned dynamically on load up (per third party code). <div id="div1287"> <!-- dynamically-generated elements will go here. --> </div> <script id="script0348710783" type="javascript/text"> </script> <script type="javascript/text"> document.getElementById('script0348710783').src='http://oneBigHairyURL'; </script> The script loaded from http://oneBigHairyURL then creates and loads elements with

How to dynamically insert a <script> tag via jQuery after page load?

China☆狼群 提交于 2019-12-16 22:22:34
问题 I'm having problems getting this to work. I first tried setting my script tags as strings and then using jquery replaceWith() to add them to the document after page load: var a = '<script type="text/javascript">some script here</script>'; $('#someelement').replaceWith(a); But I got string literal errors on that var. I then tried encoding the string like: var a = '&left;script type="text/javascript">some script here<\/script>'; but sending that to replaceWith() outputs just that string to the

Can browser handle a disposable JS file?

五迷三道 提交于 2019-12-13 23:28:58
问题 I want to hide the source of JS from direct access. So I thought to produce a disposable JS file. I use a temporary session cookie. The cookie is set before including JS file and expires then. rather than the idea itself, my exact question is that how a browser manipulate the JS file? Does it cache a copy of JS file as soon as we write <script> tag or the script tag is just a reference and the browser should have access to JS file all times? sample asp source: <html> <body> <% response

What's the simplest <script> tag with params

血红的双手。 提交于 2019-12-13 18:11:58
问题 I want to include a script tag, while providing a parameter to it. This is what I came up with so far Provide a parameter to script URL (cons: generate multiple JS files) <script src="http://example.com/something.js?P=123" type="text/javascript"></script> Hide parameter in script tag (cons: same as #1) <script src="http://example.com/scripts/123/something.js" type="text/javascript"></script> Google Analytics way (cons: ugly, complicated, global variables) <script type="text/javascript"

Can't attach local Javascript file to HTML

冷暖自知 提交于 2019-12-13 09:25:06
问题 I can't seem to attach my local Javascript file to the page: <head> <title>My Website</title> <link rel="stylesheet" type="text/css" href="Main.css" /> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"> </script> </head> <body ng-app="VideoGamesApp"> <div class="Main" ng-controller="myCtrl"> <div> <p>{{test}}</p> </div> </div> <script type="text/javascript" src='C:/Application/Application.js'></script> </body> The script: var app = angular.module(