I'm new to JS, so please bear with me if this question might not make sense.
Is it possible to parse an inline js value to a js src value?
Suppose I have this inline js.
<script>
window.foo = window.foo || {};
window.foo.cam = { 'status';'logged-out'};
</script>
This is the javascript src which I like to parse the above value to to %value%.
<script src="http://bar.com/js.php?position=bottom&login_status=%value%"></script>
It's possible to do if you dynamically add the script tag to the DOM with Javascript:
<div id="s_tag_container"></div>
<script type="text/javascript">
window.foo = window.foo || {};
window.foo.cam = {'status': 'logged-out'};
var s_tag = document.createElement('script');
s_tag.src = 'http://bar.com/js.php?position=bottom&login_status='+window.foo.cam.status;
document.getElementById('s_tag_container').appendChild(s_tag);
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.