Crossite scripting using script tag, change src of script tag, can id be used for script tag

<body>
<!-- some html code -->

<script src='some.js'></script>

<!-- some html code -->

</body>

script some.js loads the form. when I click update in this form, I don’t submit the form instead, I form a query string and want to send it as some.js? key = value

Now I need to change the src of the script tag.

If we change src, will it work by requesting new content again? Is it possible to use an identifier for a script tag, and if it will be supported by all browsers?

when new content is received, I will clear the old content displayed by this script. I think it's better to have a div and put all the contents inside this div. I am rewriting script.js to script.php in my htaccess, just showing users that this is just javascript access or no problem for me if I give .php.

The above is a basic requirement.

We just need to use a script tag that will retrieve content from another site and should be updated here.

You can give recommendations on using this in a standard way, which will include updating the content from site x.

so this is what people say, as a cross-site site script, at javascript request and please add more terms if they exist so that I update myself.

any answer would be helpful.

+3
4

W3C (http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1) 'script' ( 'id'), . 'script' 'src' , . JSONP Cross-Origin Resource Sharing (http://www.w3.org/TR/cors/) - , , .

+2

@tpeczek, script src , script.
:

var oldScript = document.getElementById('someID');
var script = document.createElement("script");        
script.setAttribute("type","text/javascript");                
script.setAttribute("id","someID");
script.setAttribute("src",url);

if (oldScript == null) {               
    document.body.appendChild(script);
} else {
    document.body.replaceChild(script, oldScript);
}
+2

script src, some.js?

+1

UPDATE: As a global attribute, supported idfor script in HTML5.

+1
source

Source: https://habr.com/ru/post/1770266/


All Articles