Hejsan, jag undrar om någon vet hur man
kan lista fram vilka styles som finns i en .css fil?
Låt säga att jag har en sida som heter TaFram.asp
och en css fil som heter Style.css.
Och nu vill jag ta fram alla olika styles jag har i den där Style.css filen
till min TaFram.asp fil, och lista upp dem i en dropdownbox..
Någon som har nått bra tips, eller ett script som gör detta?
<select name="css">
<%
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(Server.MapPath("style.css"))
strCSS = objTS.ReadAll
objTS.Close : Set objTS = Nothing
Set objFSO = Nothing
Set RegExp = New RegExp
With RegExp
.Global = True
.IgnoreCase = True
.Pattern = "[^\{]*\{[^\}]*\}"
End With
Set objMatches = RegExp.Execute(strCSS)
For Each Match In objMatches
RegExp.Pattern = "\{[^\}]*\}"
strCSS = strCSS & "||" & RegExp.Replace(Match.Value, "")
Next
Set objMatches = Nothing : Set RegExp = Nothing
arrCSS = Split(strCSS, "||")
For i = 1 To UBound(arrCSS)
Response.Write("<option>" & arrCSS(i) & "</option>" & vbCrLf)
Next
%>
</select>
Den där koden skriver även ut kommentarer i css koden.
Skulle kunna gå att lösa genom att enbart tillåta a-z och . som första tecken.
Och om han vill ha hjälp med det då? ;)
/red Äsch, koden blev fel. Återkommer snart igen. ;) /red2 Såja!
<select name="css">
<%
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(Server.MapPath("style.css"))
strCSS = objTS.ReadAll
objTS.Close : Set objTS = Nothing
Set objFSO = Nothing
Set RegExp = New RegExp
With RegExp
.Global = True
.IgnoreCase = True
.Pattern = "[a-zA-Z0-9\.\#]{1}[^\{]*\{[^\}]*\}"
End With
Set objMatches = RegExp.Execute(strCSS)
For Each Match In objMatches
RegExp.Pattern = "\{[^\}]*\}"
strCSS = strCSS & "||" & RegExp.Replace(Match.Value, "")
Next
Set objMatches = Nothing : Set RegExp = Nothing
arrCSS = Split(strCSS, "||")
For i = 1 To UBound(arrCSS)
Response.Write("<option>" & arrCSS(i) & "</option>" & vbCrLf)
Next
%>
</select>
:p
264 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2