html - Scripts not being called -


i using expressjs. scripts or css not load.

<html>   <head>     <meta http-equiv="content-type" content="text/html; charset=utf-8"/>     <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>     <meta name="apple-mobile-web-app-capable" content="yes"/>     <meta name="apple-mobile-web-app-status-bar-style" content="black"/> <title>customer info</title>      <link rel="stylesheet" href="/stylesheets/testing.css" type="text/css" media="screen" charset="utf-8"/>      <script type="text/javascript" src="/javascripts/jquery-1.9.1.js"></script>     <script src="/javascripts/jquery-ui-1.10.2.custom.js" type="text/javascript" charset="utf-8"></script>      <script type="text/javascript" src="/javascripts/testing.js"></script>      </head>    <body>         //body contents    </body> </html> 

i know problem not location. when render ejs view in express none of scripts loading. can not understand why work identical view, not one. ideas?

step 1

in node.js file locate part configure express.

it like.

 var express = require('express')                , app = express();   app.configure(function() {     //configure express codes go here  } 

in check out line of code configure folder serves static files. images,css, , js. like.

app.use(express.static(__dirname + '/public')); 

here in above case public should name of parent folder holds stylesheets , javascripts folder mentioned in above html.

like

--app.js --package.json --views/ --node_modules/ --public/      --stylesheets/         --testing.css      --javascripts/         --jquery-1.9.1.js         --jquery-ui-1.10.2.custom.js         --testing.js 

step 2

if above configured correctly can make sure

app.use(express.static(__dirname + '/public')); 

in config comes ahead of

app.use(app.router); 

so can make assure line not ignored 404 route handler written in router.

step 3

you can inspect rendered page firebug or chrome inspector , check in networks tab response received js , css files have mentioned. per question should 404 file not found , if else should update in question.

step 4

if still cant fix issue have update question node.js codes using. it.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -