css added from remote node.js but not apply on html page

The application on which m working I am calling CSS file from remote server dynamically and remote server side we are using node.js where file loads but not apply CSS on the page .

When I try to add the path other than node.js server path it works properly and when I add some CSS from javascript this also works.

I tried following option

  • loadCSS = function(href) { var href = "http://192.168.0.64:3001/public/stylesheets/enduserchat.css"; var cssLink = $(""); $("head").append(cssLink); }; // not working

  • $('head').append('http://192.168.0.64:3001/public/stylesheets/enduserchat.css" type="text/css" />') // (remote side node.js) not working

  • $('head').append('http://demo23.easternenterprise.com/webrtc/css/chats.css" type="text/css" />') // working (without node js)

  • function loadjscssfile(filename) { var fileref=document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css") fileref.setAttribute("href", "http://192.168.0.64:3001/public/stylesheets/enduserchat.css") document.getElementsByTagName("head")[0].appendChild(fileref); } // not working

  • Plz help me out for this.


    As I see, you are loading the css after creation of the webpage. But changes will work AFTER refreshing of the webpage. The solution: at server side combine all styles, javascript and html, and after that return it to the client side.

    Have a nice day!

    链接地址: http://www.djcxy.com/p/66080.html

    上一篇: 将css href属性更改为多个html页面

    下一篇: css从远程node.js添加,但不适用于html页面