Passing Querystring style parameters into Javascript file

后端 未结 2 2240
感动是毒
感动是毒 2020-12-21 15:39

Not sure if this is possible or even if I should do it, but I think it\'s quite interesting.

I have a javascript file which I\'m referencing in a flat HTML page. I\

2条回答
  •  Happy的楠姐
    2020-12-21 15:49

    This is a variation on Matt's answer. I have a similar case where I need a jQuery file to use a value that is generated in the HTML (by Razor in this case). I write the value to a meta tag, generated as it is from the controller:

    
    

    and then read it in the jQuery file:

    var sessionId = $("meta[name=sessionId]").attr("content");
    

    It's not quite the same as passing it in by querystring, but useful if that information is considered "meta-information" of the HTML page.

提交回复
热议问题