LEoREo_2247 LEoREo_2247 - 5 months ago 12
CSS Question

How to convert all "link rel stylesheet" relative path to absolute path in javascript

How I can convert all "link rel stylesheet"in html 's relative path to absolute path using javascript?


<link rel="stylesheet" type="text/css" href="/sample.css">

thing i want

<link rel="stylesheet" type="text/css" href="http://sample.com/sample.css">


Set the href attribute with the href property value:

link.setAttribute("href", link.href); // won't work in old IE

, or set the href property as itself:

link.href = link.href; // maybe different for each browser