How to add DOM element script to head section?

前端 未结 11 1098
野趣味
野趣味 2020-11-28 10:54

I want to add DOM element to head section of HTML. jQuery does not allow adding DOM element script to the head section and they execute instead, Reference.

I want t

11条回答
  •  一向
    一向 (楼主)
    2020-11-28 11:15

    I use PHP as my serverside language, so the example i will write in it - but i'm sure there is a method in your server side as well.

    Just have your serverside language add it from a variable. w/ php something like that would go as follows.

    Do note, that this will only work if the script is loaded with the page load. If you want to load it dynamically, this solution will not help you.

    PHP

    HTML

    
        
    
    

    In Summary: Decode with serverside and put it in your HTML using the server language.

提交回复
热议问题