Search code examples
javascriptparameterswidgetxssscript-tag

How to pass parameters to a Script tag?


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&amp;param_b=3"></script>

Is there a way to do this?


Two interesting links:


Solution

  • Got it. Kind of a hack, but it works pretty nice:

    var params = document.body.getElementsByTagName('script');
    query = params[0].classList;
    var param_a = query[0];
    var param_b = query[1];
    var param_c = query[2];
    

    I pass the params in the script tag as classes:

    <script src="http://path.to/widget.js" class="2 5 4"></script>
    

    This article helped a lot.