English 中文(简体)
newspaper articles link href
原标题:

How do I change the link href to css, js code for each article without manually doing it? Each article I write is seperated into different folders and I start each article with one template that links to css/reset.css etc.

This is my sample article template code: Sample Article Page

    <link href="css/slider.css" rel="stylesheet" type="text/css" media="screen" />
    <!-- jquery -->
    <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.js"></script>
    <!-- superfish -->
    <link href="css/superfish.css" rel="stylesheet" type="text/css" media="screen" />
    <script type="text/javascript" src="js/hoverIntent.js"></script>
    <script type="text/javascript" src="js/superfish.js"></script>
    <!-- initialize jquery superfish plugins -->
    <script type="text/javascript" src="js/init.js"></script>
    <!-- tabs -->
    <script src="js/ui.core.js" type="text/javascript"></script>
    <script src="js/ui.tabs.js" type="text/javascript"></script>
    <link rel="stylesheet" href="css/ui.tabs.css" type="text/css" media="screen" />
    <!-- initialize tabs -->
    <script type="text/javascript">
        $(document).ready(function(){
            $( #container-1 > ul ).tabs(); /* news and events */
            $( #container-2 > ul ).tabs(); /* pre-footer tab */
            $( #container-4 > ul ).tabs(); /* popular items */
最佳回答

It sounds like you re asking how you can use the same URL for each external file, regardless of where your page is placed.

If so, all you would need is to use absolute URLs instead of relative URLs. That is, "/foo/bar/reset.css" (note the initial slash) instead of "bar/reset.css"

Absolute URLs trace from the site root, rather than the file s current location, and so the links will be the same regardless of where you place the file.

Edit:

You would put this URL in the same place where you already put the relative URLs: That is:

<link type="text/css" rel="stylesheet" media="all" href="/foo/bar/style.css" />

instead of the

<link type="text/css" rel="stylesheet" media="all" href="bar/style.css" />

that you are using now.

问题回答

Kevin, correct me if I m wrong; you have a series of html files in different folders and you want to update all of the CSS and javascript links in them to point to a new location.

Your scenario:

wwwroot/
       |
       -- CSS/
             |
             -- reset.css
       |
       -- Javascript/
       |
       -- 20090112/
                  |
                  -- file1.html
       |
       -- 20090207/
                  |
                  -- file2.html
                  -- file3.html
       |
       -- etc.

Dreamweaver is placing everything in your CSS folder. If you want to keep the CSS files there then you need to specify correct relative paths, or else use absolute paths.

An absolute path is one that specifies the exact location of the file http://www.somedomain.com/css/reset.css is an absolute path.

A relative path defines the path from the location of the current file. So if you wanted to add reset.css to file1.html you would specify its location in this manner ../css/reset.css

Broken down this path specifies:

..           up one folder [we re now in wwwroot]
/css         the path from wwwroot
/reset.css   the filename

Does this help?





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签