简体   繁体   中英

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?

before

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM