LEoREo_2247 LEoREo_2247 - 1 year ago 114
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">

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download