Home >Web Front-end >HTML Tutorial >Problem with using href for src when referencing js files_html/css_WEB-ITnose

Problem with using href for src when referencing js files_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:17:561639browse

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.
0d8ea09b4673666cc3ece55f80d174272cacc6d41bbb37262a98f745aa00fbf0

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.
3e01c61a08c04ba603e11b1b747ce310/bootstrap/js/bootstrap.min.js">2cacc6d41bbb37262a98f745aa00fbf0

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