Home  >  Article  >  Web Front-end  >  How to modify the CSS reference of the html frontend?_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 11:58:24843browse

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

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




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);



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



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




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">    

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]);    }}

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; i327fefd8bfcee6d6b7d9cb261584e394 -1){
        link[i].href = 'style7.css';

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