search
HomeWeb Front-endHTML TutorialProblem with using href for src when referencing js files_html/css_WEB-ITnose

This post was last edited by zfzzwz on 2012-12-23 14:49:03

A rather strange question:
When using Bootstrap’s front-end framework, you need to reference bootstrap.min.js
Usually I use src to reference JS files, but it doesn’t work no matter how I use src, so I have to write
<script type="text/javascript" href="bootstrap/js/bootstrap.min.js"></script>

and it works. . However, when using W3C to check the normativeness (http://validator.w3.org), the following error is reported:
Attribute href not allowed on element script at this point.


So I knew that href is an irregular way of writing.
But the problem is, if you don’t use href and change it to src, it won’t work and the JS effect will be gone. What’s going on?
Please give me some advice. .

-----------
My website, Thought Notes http://42.121.107.221 is in internal testing, a place to record and express your thoughts

Reply to the discussion (solution)

Drag the Js file directly to the page and see if the path is "bootstrap/js/bootstrap.min.js"

Check the full path.
src="http://42.121.107.221/bootstrap/js/bootstrap.min.js"

Drag the Js file directly to the page and see if the path is "bootstrap/js/bootstrap.min .js"

The path should not be wrong, otherwise there will be no response if you use src. .

Quoting the reply from libian339 on the 1st floor: Drag the Js file directly to the page to see if the path is "bootstrap/js/bootstrap.min.js"

The path should not be wrong, otherwise use src will also be unresponsive. .
This is really hard to say, it’s always good to rule it out

Quoting the reply from zfzzwz on the 3rd floor: Quoting the reply from libian339 on the 1st floor: Drag the Js file directly to the page and see if the path is "bootstrap" /js/bootstrap.min.js"

The path should not be wrong, otherwise there will be no response if you use src. .
It’s really hard to say, it’s always better if you rule it out

I tried it and it’s really not a path problem. .

Take a look at the full path.
src="http://42.121.107.221/bootstrap/js/bootstrap.min.js"

It really works! May I ask, why is this?
Several other files I quoted are not written like this. They are just written in normal ways, which is easy to use. Why do I need to add the full path to this file?

Did you make the thought journal? Is it written in php? Can you tell me what knowledge you used to create this online battle? I have always made corporate websites before, but I have never made a forum-like website like this. Trouble.

Try this

<script type="text/javascript" src="<%=ResolveUrl("~/bootstrap/js/bootstrap.min.js")%>" ></script>

It really works! May I ask, why is this?
Several other files I cited are not written like this. They are just written in normal ways and are easy to use. Why do I need to add the full path to this file?
It’s hard to say, maybe your apache is not set up properly.

Did you make the thought journal? Is it written in php? Can you tell me what knowledge you used to create this online battle? I have always made corporate websites before, but I have never made a forum-like website like this. Trouble.

I made it, written in PHP
Knowledge used: PHP, MySQL, HTML, CSS, JS, jQuery, setting up a server environment, that’s pretty much it
I don’t know about you If you want to ask specifically, please feel free to add me on QQ 799537463 ~

Quoting the reply from wln00 on the 7th floor: Did you make the thought journal? Is it written in php? Can you tell me what knowledge you used to create this online battle? I have always made corporate websites before, but I have never made a forum-like website like this. Trouble.

I made it, written in PHP
Knowledge used: PHP, MySQL, HTML, CSS, JS, jQuery, setting up a server environment, that’s pretty much it
I don’t know about you If you want to ask specifically, please feel free to add me on QQ 799537463...
Oh, that’s pretty good. I’m working on a corporate website at 58.com. I’ve never used PHP to develop a personal website. I’m responsible for both the front desk and the back office. Yes, as long as it is HTML, CSS, Javscript, Jquery, ajax, asp.net and SQL, as well as SEO. I have developed websites before and have never made a website in the form of a forum.

Both src and href are OK, but the path to the script should be wrong.

The website is very simple and the overall layout is good.

But what is a bit strange is why there is no time for all the articles (let’s call them articles, maybe they are called ideological comparisons and webmasters) and recovery? I don’t know if it is not recorded or if it is recorded but not displayed. It is suggested that it would be better to display the time of the article and reply.

Both src and href are OK, but the path to the script should be wrong.

The path should be right, I tried it. And if it's wrong, it should be that src and href are not easy to use.

The website is very simple and the overall layout is good.

But what is a bit strange is why there is no time for all the articles (let’s call them articles, maybe they are called ideological comparisons and webmasters) and recovery? I don’t know if it is not recorded or if it is recorded but not displayed. It is suggested that it would be better to display the time of the article and reply.

Where we call posts "Si Ji"
The time to comment is in the right part of the Si Ji page

The time to comment is in the comment box, but The time will only be displayed when the mouse is hovering over it

The general idea is: the time is there, but the display is not obvious.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!