How to modify the CSS reference of the html frontend?_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:58:24
Original
838 people have browsed it

The head part of the original html frontend references a style.css style

<LINK href="Css/style.css" type="text/css" rel="stylesheet">
Copy after login




Now I want to use the style7.css style to overwrite the style. css style

First, add the style7.css style to the Head section of the html frontend. You can use the following method to achieve it

HtmlLink link = new HtmlLink();link.Attributes.Add("type", "text/css");link.Attributes.Add("rel", "stylesheet");link.Attributes.Add("href", "style7.css");this.Header.Controls.Add(link);
Copy after login



But now html The head part of the front desk references two styles



<LINK href="Css/style.css" type="text/css" rel="stylesheet">
Copy after login




The question now is: how to reference the style.css Remove it from the head of the html frontend?




Reply to discussion (solution)

            <LINK href="Css/style.css" type="text/css" rel="stylesheet">    
Copy after login

The middle one 0 is i.

var link = document.getElementsByTagName('link');for(var i = 0; i<link.length; i++){    if(link[i].href.indexOf('style.css') > -1){        link[i].parentNode.removeChild(link[i]);    }}
Copy after login

Your business logic
Add a
and go to a


Then the synthesis is to modify a
and borrow the code above
var link = document.getElementsByTagName('link');
for(var i = 0; i if(link[i].href.indexOf('style.css ') > -1){
        link[i].href = 'style7.css';

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!